在Android上使用Retrofit的Vimeo SSL错误
作者:互联网
使用Retrofit我遇到了Vimeo API的问题.我的观点是使用Retrofit在Vimeo上上传MultipartTypedOutput.
这是一些代码:
public interface VimeoUploadApi {
@PUT("/upload")
void uploadVideo(@Header("Authorization") String header,
@Body MultipartTypedOutput body,
@Query("ticket_id") String ticket_id,
BaseCallback<VideoUploadedEvent> callback);
}
public VimeoUploadApi provideVimeoUploadApi(String url) {
RestAdapter restAdapter = new RestAdapter.Builder()
.setEndpoint(url)
.setLogLevel(BuildConfig.DEBUG ? RestAdapter.LogLevel.FULL : RestAdapter.LogLevel.NONE)
.build();
return restAdapter.create(VimeoUploadApi.class);
}
private MultipartTypedOutput generateMultipartObject() {
MultipartTypedOutput multipartTypedOutput = new MultipartTypedOutput();
File file = new File(videoPath);
long totalSize = file.length();
FileProgressListener listener = new FileProgressListener(totalSize);
listener.setPath(videoPath);
multipartTypedOutput.addPart("video", new CountingTypedFile("video/mp4", file, listener));
return multipartTypedOutput;
}
并致电:
provideVimeoUploadApi(getUploadUrl(secure_link)).uploadVideo(
"Authorization: Bearer " + Environment.VIMEO_TOKEN,
generateMultipartObject(),
event.getTicket_id(),
new BaseCallback<VideoUploadedEvent>()
);
当我上传视频时,我收到如下错误:
Write error: ssl=0x98cc2800: I/O error during system call, Connection
reset by peer
retrofit.RetrofitError: Write error: ssl=0x98cc2800: I/O error during system call, Connection reset by peerCaused by: javax.net.ssl.SSLException: Write error: ssl=0x98cc2800:
I/O error during system call, Connection reset by peer
无论如何要解决它?
解决方法:
因此,由于我没有找到使用Retrofit向Vimeo发送视频的任何解决方案,我发现老式的HttpUrlConnection非常好用.
如果有人需要一些代码,我会在这里发布.
标签:android,ssl,retrofit,vimeo-api 来源: https://codeday.me/bug/20190711/1434302.html