You need to sign in to do that
Don't have an account?

Download files from Google drive
https://developers.google.com/drive/web/manage-downloads
In the above link it is given that we have to make a GET request to the downloadUrl (which we get in the response when we upload the file) in order to get the file contents.
The downloadUrl which I got after uploading file to google drive is :
"downloadUrl": "https://doc-10-cc-docs.googleusercontent.com/docs/securesc/2butu3k0aok5svkleqovepe3uqqvauqr/9o0jdpikd3jl5krf0vgcacuhfl8gro0v/1408694400000/05688347114777583261/05688347114777583261/0B602YDdndVQ6LUxZRC0wX1ZtWWs?h=16653014193614665626&e=download&gd=true"
Now i am making GET request like this:
Http http = new Http();
HttpRequest req = new HttpRequest();
req.setMethod('GET');
req.setEndpoint(downloadURL);
req.setHeader('content-type', 'text/plain');
req.setHeader('Authorization','Bearer '+accessToken);
req.setTimeout(60*1000);
HttpResponse resp = http.send(req);
My problem is that, each time i upload the file i will get different downloadUrl such that it is difficult to change the remote site settings every time.
Any way to dynamically change the remote site setting? Please help me.
In the above link it is given that we have to make a GET request to the downloadUrl (which we get in the response when we upload the file) in order to get the file contents.
The downloadUrl which I got after uploading file to google drive is :
"downloadUrl": "https://doc-10-cc-docs.googleusercontent.com/docs/securesc/2butu3k0aok5svkleqovepe3uqqvauqr/9o0jdpikd3jl5krf0vgcacuhfl8gro0v/1408694400000/05688347114777583261/05688347114777583261/0B602YDdndVQ6LUxZRC0wX1ZtWWs?h=16653014193614665626&e=download&gd=true"
Now i am making GET request like this:
Http http = new Http();
HttpRequest req = new HttpRequest();
req.setMethod('GET');
req.setEndpoint(downloadURL);
req.setHeader('content-type', 'text/plain');
req.setHeader('Authorization','Bearer '+accessToken);
req.setTimeout(60*1000);
HttpResponse resp = http.send(req);
My problem is that, each time i upload the file i will get different downloadUrl such that it is difficult to change the remote site settings every time.
Any way to dynamically change the remote site setting? Please help me.
req.setEndpoint('https://googledrive.com/host/'+''+ID);
instead of req.setEndpoint(downloadURL);
where ID is the file id which we get in the response.
All Answers
req.setEndpoint('https://googledrive.com/host/'+''+ID);
instead of req.setEndpoint(downloadURL);
where ID is the file id which we get in the response.
how can i upload files from salesforce to google drive?
because i m trying to uploading bt i cant upload.
this is my code for file upload:
public PageReference DriveUploadAuth()
{
document.AuthorId = UserInfo.getUserId();
document.FolderId = UserInfo.getUserId();
try
{
insert document;
}
catch(DMLException e){
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading file'));
return null;
}
finally {
document.body = null; // clears the viewstate
document = new Document();
}
PageReference pg = new PageReference(GoogleDriveAuthUri (key , redirect_uri)) ;
return pg;
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'File uploaded successfully'));
return null;
}
nd my second question is that can we download files from google drive to salesforce??? nd how?? i should make a folder first ..m i right??
is this right way??