+ Start a Discussion
Jamie ThompsonJamie Thompson 

How to move files from Salesforce to Amazon S3?

Hello everyone!

I am using Salesforce Community to develop a mobile application. I want to store files (file feeds) into Amazon S3 instead of Salesforce. Does anyone know how to do that? Any help would be much appreciated.
SonamSonam (Salesforce Developers) 
hi Jamie, Just wish to check if I understand this correctly - so you are trying to save the Chatter Files on a 3rd party rather than salesforce? or is it that the files will still be in Salesforce but you wish to access it in Amazon S3 as well(opposite of https://help.salesforce.com/apex/HTViewHelpDoc?id=admin_files_connect_overview.htm&language=en_US)
Jamie ThompsonJamie Thompson
Hi Sonam. Thanks for the reply.

Yes, I want to save Chatter Files on a 3rd party rather than Salesforce. The files will not be on SF.
S3- Link is FREE App for Salesforce - Amazon Connector. Its also available on Appexchange. 

    Attach file related to any Salesforce object on Amazon.
    Ulimited free storage for one year.
    Multiple file uplaod.
    No file size limit for upload.
    File access control capabiliy.
    Track file downloads by users.
    File exlorer capability.


Here is our email address. Let us know if you have any query.

Arun BhardwajArun Bhardwaj
User-added image       
 String today = Datetime.now().format('dd-MM-yyyy');
         Blob csvBlob = blob.valueOf(csvFile );
        // Blob csvBlob= EncodingUtil.base64Decode(csvFile);
        String csvName = ObjectLabelName+' Data as on '+today+'.csv';
        string filename,filetype='';
        String Sdate = Datetime.now().formatGMT('EEE,   dd MMM yyyy HH:mm:ss z');
        filename=ObjectLabelName +'.csv';
        //setup variables
        String formattedDateString = Datetime.now().format('EEE, dd MMM yyyy HH:mm:ss z','America/Denver');    //this is needed for the PUT operation and the generation of the signature.  I use my local time zone.
        String bucketname='datadrchiving/test';
        String method='PUT';
        String contentType = 'text/csv';
        HttpRequest req = new HttpRequest();
        req.setHeader('Content-Length', string.valueOf(csvFile.length()));
        req.setHeader('Content-Type', contentType);
        req.setHeader('Date', formattedDateString);
        req.setHeader('ACL', 'public-read-write');
        String stringToSign = 'PUT\n\n' + formattedDateString + '\n\n' + '/' + bucketname + '/' + filename;
      //  String signed = createSignature(stringToSign,secret);
       // String authHeader = 'AWS' + ' ' + key + ':' + signed;
         string authHeader=createAuthHeader(method,contentType,filename,formattedDateString,bucketname,key,secret);
        system.debug('Auth header***');
        system.debug('blob value***'+csvBlob);
        Http http = new Http();
            //Execute web service call
            HTTPResponse res = http.send(req);
            System.debug('RESPONSE STRING: ' + res.toString());
            System.debug('RESPONSE STATUS: '+res.getStatus());
            System.debug('STATUS_CODE: '+res.getStatusCode());
        catch(System.CalloutException e) 
            system.debug('AWS Service Callout Exception: ' + e.getMessage());

Response is coming 200 ok from AWS server  but unable to find the CSV in aws account. Could you please check and help on this. 
Kevin PoklertKevin Poklert
I had a successful experience in creating a direct connection between SFDC and Amazon with help of cloud-based service - Skyvia (https://skyvia.com/data-integration/integrate-salesforce-amazon-s3).
The service is totally no coding and has flexible scheduling features.
Sonam MeshramSonam Meshram
I came across the newly developed app in AppExchange named Drag, Drop & Upload Files to Amazon S3 for this am using the same and its very easy to understand and having advanced features like you can delete/view your files from salesforce, and also provide some additional customization .
Please have look:https://sforce.co/34y12sL