在 Android 上使用 Retrofit 时出现 Vimeo SSL 错误
Vimeo SSL error using Retrofit on Android
我在 Vimeo API
使用 Retrofit 时遇到问题。我的观点是使用 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 peer
Caused by: javax.net.ssl.SSLException: Write error: ssl=0x98cc2800:
I/O error during system call, Connection reset by peer
是否要修复它?
因此,由于我没有找到任何使用 Retrofit
将视频发送到 Vimeo
的解决方案,我发现旧版 HttpUrlConnection
工作得很好。
如果有人需要一些代码,我会 post 在这里。
我在 Vimeo API
使用 Retrofit 时遇到问题。我的观点是使用 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 peer
Caused by: javax.net.ssl.SSLException: Write error: ssl=0x98cc2800: I/O error during system call, Connection reset by peer
是否要修复它?
因此,由于我没有找到任何使用 Retrofit
将视频发送到 Vimeo
的解决方案,我发现旧版 HttpUrlConnection
工作得很好。
如果有人需要一些代码,我会 post 在这里。