Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Info

If you would like to get an old version of a file, you should add id of an old version file into fileoObjectIds list.

getAttachmentURLs() method can be used to generate both Open and Download URLs. Changing the response-content-disposition values in the requestParameters map will change the URL type.

For an open URL, the corresponding response-content-disposition value should include “inline”

For a download URL, the corresponding response-content-disposition value should include “attachment”

 

The sample script below returns a list of download URLs for two S-Drive files under an Account record.

Code Block
List<Id> accIds = new List<Id>();
accIds.add('0013G00000RaoJ3QAJ'); //Parent account record ID
accIds.add('0013G00000RaoJ3QAJ'); //Parent account record ID
List<Id> fileIds = new List<Id>();
fileIds.add('a003G000007MCVhQAO'); //File record ID
fileIds.add('a003G000007MCVmQAO'); //File record ID
Map<String,String> reqParam = new Map<String,String>();
reqParam.put('response-content-disposition', 'attachment; filename=Agreement.pdf');
reqParam.put('response-content-disposition', 'attachment; filename=SampleImage.png');

List<String> downloadURLs = SDriveTools.getAttachmentURLs(accIds, fileIds, 212324, reqParam);
String agreementFileURL = downloadURLs[0];
String imageFileURL = downloadURLs[1];

 

The sample script below returns a list of open URLs for two S-Drive files under an Account record:

Code Block
List<Id> accIds = new List<Id>();
accIds.add('0013G00000RaoJ3QAJ'); //Parent account record ID
accIds.add('0013G00000RaoJ3QAJ'); //Parent account record ID
List<Id> fileIds = new List<Id>();
fileIds.add('a003G000007MCVhQAO'); //File record ID
fileIds.add('a003G000007MCVmQAO'); //File record ID
Map<String,String> reqParam= new Map<String,String>();
reqParam.put('response-content-disposition', 'inline; filename=Agreement.pdf');
reqParam.put('response-content-disposition', 'inline; filename=SampleImage.png');

List<String> openURLs = SDriveTools.getAttachmentURLs(accIds, fileIds, 212324, reqParam);
String agreementFileURL = openURLs[0];
String imageFileURL = openURLs[1];

 

It is also possible to get an open or download URL for a single file.

 

The sample script below returns a one-element list of open URLs for an S-Drive file under an Account record:

Code Block
List<Id> accIds = new List<Id>();
accIds.add('0013G00000RaoJ3QAJ'); //Parent account record ID
List<Id> fileIds = new List<Id>();
fileIds.add('a003G000007MCVmQAO'); //File record ID
Map<String,String> reqParam= new Map<String,String>();
reqParam.put('response-content-disposition', 'inline; filename=Agreement.pdf');

List<String> openURLs = SDriveTools.getAttachmentURLs(accIds, fileIds, 212324, reqParam);
String agreementFileURL = openURLs[0];