0

My packaged app gets images from google drive and then display them on the side. But I can't get the images to be displayed. I am trying to get the url of the image so that I can put that url in an image source. The image url that I am getting is actually an html page rather than jpeg, png etc. I have looked at the reference guide for google picker but nothing seems to work.

I am using this

    function pickerCallback(data) {
    if (data.action == google.picker.Action.PICKED) {   
    var fileId = data.docs[0].id;
    fileName = data.docs[0].name;
    imgURL = data.docs[0].url;
    } 

I want to use imgURL as the source for image selection but imgURL is not something like "https//:www.example.com/image.jpg. It is rather an html page I want something that ends with file type only then it will be able to display the image. Please let me know how can I get the image to be displayed in html page of my packaged app after selecting it from google drive.

Ali Afshar
  • 40,967
  • 12
  • 95
  • 109
user1745649
  • 137
  • 1
  • 9

1 Answers1

1

You should fetch the metadata of the image, then use the webContentLink of the image, then the user can view it in a logged in browser. See the documentation on downloads for more information.

Ali Afshar
  • 40,967
  • 12
  • 95
  • 109
  • One thing I am wondering what is the Drive file instance? /** * Download a file's content. * * param {File} file Drive File instance. * param {Function} callback Function to call when the request is complete. */ function downloadFile(file, callback) { if (file.downloadUrl) {...... Is it this: data.docs[0]? or data[google.picker.Response.DOCUMENTS][0]; from https://developers.google.com/picker/docs/ I just don't know what arguments should I send when I call downloadfile function. Since fileId is data.docs[0].Id, therefore file instance will be just data.docs[0]? – user1745649 Jan 10 '13 at 06:35