I've used Google Picker API to select a file from user's Google drive. I've all the metadata about the file which is returned by this API. But I'm stuck at how to download this file on my server.
Using the following link to download the file only downloads some files properly while the others are corrupted:
"https://drive.google.com/uc?export=download&id="+fileid
I'm using rails version 3.2
Any helps would be much appreciated. Thanks.
Here's what I did:
Got the file id of the file I need to download from Picker API, then passed this file id to google client api to get the direct download url of the document:
gapi.client.request({
'path': '/drive/v2/files/'+file_id
'method': 'GET'
callback: function (responsejs, responsetxt){
var downloadUrl = responsejs.downloadUrl;
}
});
After getting this direct download url, I then used the "open-uri" in rails to download and save the file on my server.