Search code examples
javagdata-apipicasa

Get Picasa's image direct URL using gdata-java-client


I upload image to Picasa and get response:

PhotoEntry returnedPhoto = myService.insert(feedUrl, PhotoEntry.class, myMedia);

Now I want to extract direct URL of an image. If I do...

for (Link link : returnedPhoto.getLinks()) {
    System.out.println(link.getHref());
}

...I get correct URLs, but they are indirect, e.g. https://picasaweb.google.com/data/feed/api/user/blablabla Such URL points not to image-file, but to Picasa page with this image inside.

And what I want to get is URL like this one: https://lh4.googleusercontent.com/blablabla/blablabla/blabla/bla/my_image.jpg

I've figured out that .Net users can do this using some class "PicasaQuery". But I guess this class is present only in .Net version, because I can't find it in gdata-java-library. How can I extract direct URL of an image in other way?


Solution

  • Perhaps this answer will help you.

    PhotoEntry returnedPhoto = myService.insert(feedUrl, PhotoEntry.class, myMedia);
    String href = returnedPhoto.getHtmlLink().getHref();
    if (returnedPhoto.getMediaContents().size() > 0) {
      href = returnedPhoto.getMediaContents().get(0).getUrl();
    }
    System.out.println(href);