【发布时间】:2011-05-28 06:02:16
【问题描述】:
我一直在尝试使用 Direct Uploading 通过 JavaAPI 将视频上传到 YouTube。我在调用 insert() 方法时遇到问题,我收到带有错误消息的 IOException
“将请求正文写入服务器时出错”
我已验证我正在创建的 File 对象以及我的 VideoEntry 对象中的所有详细信息都是正确的。我一直在使用 Fiddler 来监控我机器上的活动,并且没有向上传 API 发出请求,所以问题不存在。这是我正在使用的代码的摘要:
VideoEntry newVideo = new VideoEntry();
//Defined video properties such as title and description here.
MediaFileSource ms = new MediaFileSource(videoFile, "video/flv");
newVideo.setMediaSource(ms);
VideoEntry createdEntry = settings.insert(new URL(apiUrl), newVideo);
在插入调用时抛出 IOException(设置是我的 YouTubeService 实例),并且 API URL 似乎是正确的。
在此之前,我已经使用 C# API 成功上传了这个视频,所以我知道视频文件是有效的。
--更新 这是 apiURL 值:
http://uploads.gdata.youtube.com/feeds/api/users/default/uploads
【问题讨论】:
-
是的,每次我尝试运行这段代码都会失败
-
我可以看看 'apiUrl' 是如何创建的吗?
-
我有同样的问题..你有没有得到同样的解决方案......如果是的话,你可以分享一下..