0

I'm working with drive v2 API to upload files to google drive using Oauth2.0. This is how I get the thumbnail link of the file.

com.google.api.services.drive.model.File fileMetadata = new com.google.api.services.drive.model.File();
        fileMetadata.setParents(Arrays.asList(new ParentReference().setId(parentFolderId)));
        fileMetadata.setTitle(file.getName());
        fileMetadata.setMimeType(type);

        java.io.File filePath = new java.io.File(file.getAbsolutePath());
        FileContent mediaContent = new FileContent(type, filePath);
        com.google.api.services.drive.model.File f = service.files().insert(fileMetadata, mediaContent).execute();
String thumbnailLink = f.getThumbnailLink()

I'm using this thumbnailLink to show images in my web application. Does this thumbnailLink will have validity? Because when i tried to use the thumbnail link after sometime i got an 403 error.

Your client does not have permission to get URL /Bvz7wBXoC_pXJWfbJ44iEryxrXxB5w7JLU9He8ErJ2OjWEZg2EJCqBL1ElfIUdVx--IHqw=s220 from this server. (Client IP address: x.x.x.x)

I have tried with these Google Drive - Unable to download thumbnails with an authenticated (OAuth2) request , https://productforums.google.com/forum/#!topic/chromebook-central/YvNs0J5IgS0 Still I'm facing the same issue. Is there any way I can overcome this? When i upload the same image again it works for sometime but after sometime again the same issue.

Jayashree
  • 23
  • 4

1 Answers1

0

thumbnailLink according to docs has

A short-lived link to the file's thumbnail, if available. Typically lasts on the order of hours. Only populated when the requesting app can access the file's content.

So it was only working as indicated in the docs.

ReyAnthonyRenacia
  • 17,219
  • 5
  • 37
  • 56