基于对等+浏览器的连接重置上传YouTube视频

时间:2014-01-29 09:23:16

标签: youtube-api

我正在尝试从android进行基于浏览器的上传。在第一步中,移动设备要求我的服务器从youtube获取网址和令牌。移动设备从服务器获得后,移动设备将视频上传到youtube。但有时在视频上传后可以在youtube上看到“Connection Reset By Peer”异常。如何避免此错误,或者至少检查视频是否正确上传? 另一件事,我没有在响应中得到youtube_VideoId(在没有例外的情况下)。

这是上传步骤的代码:

   File file = new File(fileName);
    try {
        HttpClient client = new DefaultHttpClient();
        String postURL =  url + "?nexturl=http://example.com";
        HttpPost post = new HttpPost(postURL);
        FileBody bin = new FileBody(file);
        MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
        reqEntity.addPart("email", new StringBody("XXX@gmail.com", "text/plain", Charset.forName("UTF-8")));
        reqEntity.addPart("token", new StringBody(token));
        reqEntity.addPart("uploadfile", bin);
        this.totalSize = bin.getContentLength();
        post.setEntity(reqEntity);
        HttpResponse response = client.execute(post);
        HttpEntity resEntity = response.getEntity();

1 个答案:

答案 0 :(得分:0)

如果有很长的视频,连接重置可能会发生。我知道有超过一个小时的连接打开了一个错误。

您可以查看YouTube direct Lite for Android项目以查看视频状态和处理状态。