Uploading videos onto Youtube?

IOException when Uploading Videos to YouTube via Java API

  • I have been attempting to upload videos to YouTube via the JavaAPI using Direct Uploading. I have been having a problem when I call the insert() method, I get a IOException with the error message "Error writing request body to the server" I have verified that the File object I am creating is correct as well as all the details in my VideoEntry object. I have been using Fiddler to monitor the activity from my machine and no request is made to the upload API so the problem is not there. Here is a summary of the code I am using: 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); The IOException is thrown on the insert call (settings is my YouTubeService instance) and the API URL appears to be correct. Prior to this I have succeeded in uploading this video using the C# API so I know the video file is valid. --Update This is the apiURL value: http://uploads.gdata.youtube.com/feeds/api/users/default/uploads

  • Answer:

    If you are under a firewall env and had configured your proxy settings in jvm system properties. The try configuring your youtube service as: service.setChunkedMediaUpload(MediaService.NO_CHUNKED_MEDIA_REQUEST); or in your case settings.setChunkedMediaUpload(MediaService.NO_CHUNKED_MEDIA_REQUEST); since as you say is your YouTubeService instance. hope this helps.

lorddaveyjohno at Stack Overflow Visit the source

Was this solution helpful to you?

Other answers

Make certain that videoFile actually points to the correct local file. The File(String) constructor won't verify that it actually exists. The MediaFileSource constructor and VideoEntry.setMediaSource() method also never check that the file is valid. The error message "Error writing request body to the server" sounds like the insert method can not find the body of the message it is trying to send. File videoFile = new File("..."); if (videoFile.exists() == false) { System.err.println("FAIL"); } to test if the file exists.

RD1

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.