0

enter image description here

please refer above link for reference.

I am using drive rest API for interacting with files from google drive. my problem is when tries to load thumbnail images (which is got from google drive meta data) i got following error in response.

(Reload the page to get source for: https://lh6.googleusercontent.com/PIkXnvV5LN71K8UdvltrFIS7WpKOiXHnJCIvPRsq0ma_XU_gzEFKrfnc6hYFIojM_4_kNA =w100-h100)

  • however it works fine sometimes and loads the image perfectly.
  • Also i checked the link in new tab which is also works perfectly.

here is my code for java script

--link used for meta data

var googleLink = 'https://www.googleapis.com/drive/v2/files?q="'+attachmentId+'" in parents and mimeType != "application/vnd.google-apps.folder"&access_token='+that.getAccessToken();

--code for render image links in browser

for(var i = 0; i < files.items.length; i++){
        var div = $('<div class="row">');
        var link = $('<a href="'+files.items[i]['downloadUrl']+"&access_token="+upload.getAccessToken()+'">');

        if(files.items[i]['thumbnailLink'] != undefined){
            var thumbnailUrl = files.items[i]['thumbnailLink'].split("=");
            var linkUrl = thumbnailUrl[0]+"=w100-h100";
            var image = $('<img src="'+files.items[i]['iconLink']+'" data-src="'+linkUrl+'" style="padding:2px; float:left; height:auto; width:auto;" onload="loadPreviewImage(this)">');
            link.append(image);
        }else{
            div.append($('<img src="'+files.items[i]['iconLink']+'" style="padding:2px; float:left;">'));           
        }
        link.append(files.items[i]['originalFilename']);
        div.append(link);
        td.append(div);
    }

//function for loading thumbnail image
function loadPreviewImage(element){
    var img = $(element);
    img.src = img.dataset.src;
}
Bharat
  • 2,441
  • 3
  • 24
  • 36

2 Answers2

0

You error 403 may occur if you disable the Google Drive setting called Allow users to install Google Drive apps. This might be a good thing to check if you are certain that Google Drive is already enabled.

It is also suggested to clear your cache first. If that doesn't work, try running a malware scan using a malware/virus scanner.

You may check these related threads:

Community
  • 1
  • 1
abielita
  • 13,147
  • 2
  • 17
  • 59
-2

The issue I was having was not seeing the Google Doc icon and instead seeing a broken image. But I was able to resolve it by realizing I was having the same request issue from a third-party so I went into the internet settings of the computer and resetting them to the default.

Start > Control Panel > Internet Options > Tabs (Security/Privacy/Advanced) = Default