Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

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 ?

share|improve this question

2 Answers 2

up vote 1 down vote accepted
 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 .

share|improve this answer
    
Above code working fine and finaly my this problem solve. –  sandeep Aug 2 at 13:02
    
Sir i have one more issue that how i can get download link in dropbox for uploaded file . –  sandeep Aug 2 at 13:14
    
When you preview at top you have down arrow for you to download file from drop box.Hope that helps –  Mohith Shrivastava Aug 2 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. –  sandeep Aug 4 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.

share|improve this answer
    
sir i want the link of single file among more files. –  sandeep Aug 2 at 8:39
    
In JSON you will get download link of each file associated with its other information by which you can download them. @sandeep –  regal Aug 2 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. –  sandeep Aug 2 at 9:21
    
Have answered the same .Pls take a look.Thanks –  Mohith Shrivastava Aug 2 at 9:46
    
@regal The body will be empty .A location variable in header is needed for download. –  Mohith Shrivastava Aug 2 at 9:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.