Wednesday, March 21, 2012

[YouTube-API] Re: Resumable PUT request gets redirect.

Hello AJ,


 I happen to have some code to do resumable uploads using the Java
client library. I just gave it a try and it worked as expected (i.e.
it sent an initial POST to the /resumable/... URL).


 MediaFileSource mediaFile = new MediaFileSource(new File("/path/to/
file.mov"), "movie/quicktime");
 URL createUploadUrl = new URL("http://uploads.gdata.youtube.com/
resumable/feeds/api/users/default/uploads
");

 VideoEntry newEntry = new VideoEntry();
 YouTubeMediaGroup mg = newEntry.getOrCreateMediaGroup();
 mg.setTitle(new MediaTitle());
 mg.getTitle().setPlainTextContent("Test from Java");
 mg.addCategory(new MediaCategory(YouTubeNamespace.CATEGORY_SCHEME,
"Autos"));
 mg.setKeywords(new MediaKeywords());
 mg.getKeywords().addKeyword("cars");
 mg.setDescription(new MediaDescription());
 mg.getDescription().setPlainTextContent("My description");

 ResumableGDataFileUploader.Builder builder = new
ResumableGDataFileUploader.Builder(service,
   createUploadUrl, mediaFile, newEntry);
 Future<ResponseMessage> futureResponse = builder.build().start();
 ResponseMessage response = futureResponse.get();
 VideoEntry videoEntry = new VideoEntry();
 videoEntry.parseAtom(new ExtensionProfile(),
response.getInputStream());
 // Do what you want with the newly created VideoEntry


Cheers,
-Jeff Posnick, YouTube API Team
groups.google.com/group/youtube-api-gdata | apiblog.youtube.com |
@YouTubeDev


On Mar 19, 6:01 pm, AJG <ajgreg...@gmail.com> wrote:
> Hi Jeff, Actually, I'm using the java gdata api
> (ResumableGDataFileUploader) so I'm assuming its doing the right thing
> regarding POST/PUT.
> Is that a bad assumption?
>
> -Aj
>
>
>
>
>
>
>
> On Monday, March 19, 2012 12:28:28 PM UTC-7, Jeffrey Posnick wrote:
>
> > Hello AJ,
>
> >  To begin the resumable uploads flow, you're supposed to send a POST
> > to
> >http://uploads.gdata.youtube.com/resumable/feeds/api/users/default/up...,
>
> > not a PUT. Can you try it with a POST?
>
> >https://developers.google.com/youtube/2.0/developers_guide_protocol_r...
>
> > Cheers,
> > -Jeff Posnick, YouTube API Team
> > groups.google.com/group/youtube-api-gdata | apiblog.youtube.com |
> > @YouTubeDev
> > On Mar 14, 7:03 pm, AJG <ajgreg...@gmail.com> wrote:
> > > Is there any reason that the API would return a redirect when a PUT is
> > done
> > > to the resumable
> > > "http://uploads.gdata.youtube.com/resumable/feeds/api/users/default/up..."
>
> > > URL?
>
> > > It looks like it only happens with larger uploads.
>
> > > A POST upload of the same file to the
> > > "http://uploads.gdata.youtube.com/feeds/api/users/default/uploads" URL
> > > works ok.
>
> > > Any ideas?
>
> > > Thanks,
> > > -Aj

--
You received this message because you are subscribed to the Google Groups "YouTube APIs Developer Forum" group.
To post to this group, send email to youtube-api-gdata@googlegroups.com.
To unsubscribe from this group, send email to youtube-api-gdata+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/youtube-api-gdata?hl=en.

No comments:

Post a Comment