I am doing integration salesforce with box.com so after uploading file i want the download that file.Like in google drive we set approval_prompt=force and response body contain webContentLink for to download that file.How i can get box.com downloadable link ?
2 Answers
public static String downloadBoxFile(String fileId){
BoxAuthParser bparser;
bparser=RefreshTokenrequest();
Http h = new Http();
HttpRequest req = new HttpRequest();
string endPointValue = 'https://api.box.com/2.0/files/';
endPointValue=endPointValue+fileId+'/content';
req.setEndpoint(endPointValue);
req.setMethod('GET');
req.setHeader('Authorization', 'Bearer '+bparser.access_token);
HttpResponse res = h.send(req);
system.debug('pANY'+res.getBody());
return res.getHeader('Location');
}
The above method should help you.The GET request header has a location and that returns the URL for download of the file .
-
-
Sir i have one more issue that how i can get download link in dropbox for uploaded file .– sandeepCommented Aug 2, 2014 at 13:14
-
When you preview at top you have down arrow for you to download file from drop box.Hope that helps Commented Aug 2, 2014 at 14:07
-
I want the link of file in response body so using this link i can download uploaded file on dro.box. I want link of uploaded file in dropbox using rest api.– sandeepCommented Aug 4, 2014 at 5:39
This is the endpoint to get all files from box.com
https://api.box.com/2.0/folders/0/items?limit=5&offset=0
With file Id you can get file download information in json format.
-
-
In JSON you will get download link of each file associated with its other information by which you can download them. @sandeep– AshwaniCommented Aug 2, 2014 at 8:46
-
I am not getting link of file but i am getting id and name of uploaded file so now i can get url of uploaded file using id or name of file.– sandeepCommented Aug 2, 2014 at 9:21
-
@regal The body will be empty .A location variable in header is needed for download. Commented Aug 2, 2014 at 9:47
-
Thanks above link very helpful for me and my problem solved.– sandeepCommented Aug 2, 2014 at 13:15