You can use SDriveTools API calls for uploading the S-Drive Attachments/Folders Files to Amazon. For this, you will need to use below methods:
...
initializeMultiPartUpload()
copyPartMultiPartUpload()
completeMultiPartUpload()
deleteMultiParts()
abortMultiPartUpload()
Html Policy
Code Block |
---|
{ "expiration": "2014-03-12T12:47:13.893Z", "conditions": [ {"acl": "private" }, {"bucket": "cg--81..." }, ["starts-with", "$Content-Disposition", "attachment; filename"], ["starts-with", "$key", "a038…"], {"x-amz-server-side-encryption": "AES256"}, {"x-amz-cedential": "[AccessKey/20140312/us-east-1/s3/aws4_request"}, {"x-amz-algorithm": "AWS4-HMAC-SHA256"}, {"x-amz-date": "20140312T122020Z"} ] } |
Exceptions and Reasons for Upload Operations
[SDriveException]"Parent Folder IDs must be the same for all file records that are being uploaded".
[Reason] If Parent__c values which are passed in with the SObjects are not same for all S3Object.
[Solution] Give the parent folder ids the same for all S3Objects.
[SDriveException]"A file with the same name exists in the target folder (fileName) ".
[Reason] This exception occurs if a file with the same name exists in the same folder for S3Objects.The same file name condition holds when the file is not a WIP (WIP_c =false) file or the file is a WIP file (WIP_c =true) with the same file namebutithasbeenuploadedbyanotheruserlessthan12 hours ago.
[Solution]Upload files with different file names or delete the previously existing files before the upload.
[SDriveException]"Error occurred while checking the files to upload! File Name, File Size cannot be blank (fileName)".
[Reason]If the file name or file size fields that have been passed in with the SObject are null or empty.
[Solution]File name and file size is required for upload. Thus, pass non-blank values in with the SObject.
[SDriveException]"Name cannot start with a space or a dot and cannot contain any of the following characters: \\ /: ? \" < > | (fileName)".
[Reason]If the file name is invalid. Invalid name means, file name starts with a spaceor a dot and contains any of the following characters: \ / : ? \" < > |
[Solution]Do not upload a file with the name starting with space or a dot and contain any of the following characters: \ / : * ? \" < > | ~
[SDriveException]"You cannot upload a zero-length file (fileName)".
[Reason] If the file size is 0.
[Solution] Upload files that are greater in size than zero.
[SDriveException]"Files greater than (maxFileSize) cannot be uploaded. Please contact your system administrator for the file size limits! (fileName)".
[Reason]File being uploaded has a size greater than the maximum file size limit (MAX_FILE_SIZE configuration in S-Drive Configuration page).
[Solution]Do not upload files whose size greater than MAX_FILE_SIZE. Or Increase the MAX_FILE_SIZE configuration in S-Drive Configuration page.
[SDriveException]"Invalid parent id specified. Check your function parameters!".
[Reason] If object (parent) id, which is passed as a parameter, is not a Salesforce.com 15 or 18 characters long ID.
[Solution]Pass 15-character or 18-characterSalesforce.com ID as objectId parameter.
...
Error Messagesof ResultObject and Reasons
[errorMessage]"Wip Id is null! ".
[Reason] If wipId in the wipIds list parameter is null.
[Solution] Do not pass null Salesforce.com IDs of file objects.
[errorMessage]"'No such wip file with provided id: (wipId) ".
[Reason]If wipId in wipIds list is not available.
[Solution]Pass correct and available Salesforce.com ids of files objects.
[errorMessage]"There is no wip files".
[Reason]If all of wipId in wipIds list is null or wipIds' size is 0.
[Solution]Pass wipIds with length greater than0 and non-null string values.
[errorMessage]" Insufficient Privileges. You do not have not access to update operation".
[Reason]If Object-level security for update access is not allowed.
[Solution] Make sure that update access is allowed for your profile.
Html upload example:
Code Block |
---|
<form> File : <input type="file" name="file" id="file" /> <input type="button" value="Upload" onclick="htmlUpload();"/> </form> <script type="text/javascript"> var uploadFile ; document.getElementById('file').addEventListener('change', handleFileSelect,false); function handleFileSelect(evt) { var fileName = evt.currentTarget.files[0].name ; var fileSize = evt.currentTarget.files[0].size; uploadFile = evt.currentTarget.files[0]; //Call initializeUpload() method } function htmlUpload() { var fd = new FormData(); fd.append('key', '{!uploadRequestInfos.fileLocation}'); fd.append('AWSAccessKeyIdacl', '{!accessKey}private'); fd.append('aclx-amz-credential', 'private{!uploadRequestInfos.awsCredential}'); fd.append('policyx-amz-date', '{!uploadRequestInfos.policytimeStamp}'); fd.append('signaturepolicy', '{!uploadRequestInfos.signaturepolicy}'); fd.append('x-amz-algorithm', 'AWS4-HMAC-SHA256'); fd.append('x-amz-server-side-encryption', 'AES256'); fd.append('Content-Disposition', 'attachment; filename=\"'+ '{!uploadRequestInfos.fileName}' +'\"'); fd.append('x-amz-signature', '{!uploadRequestInfos.signature}'); fd.append("file",uploadFile); var xhr = new XMLHttpRequest(); xhr.addEventListener("load", htmlUploadComplete, false); xhr.addEventListener("error", htmlUploadFailed, false); xhr.open('POST', 'https://’ + '{!bucketName}' + '. ' + '{!region}' + '.s3.amazonaws.com/', true); // if region is us-east-1. leave region blank, xhr.send(fd); } function htmlUploadComplete(evt) { //Call completeUpload() method } function htmlUploadFailed(evt) { //Call cancelUpload() method } </script> |
...