+ Reply to Thread
Results 1 to 3 of 3
This is a discussion on Downloading Attachments to Fileserver with PHP within the Salesforce Coding Discussions forums, part of the Salesforce category; Has anyone been able to use php to download attachments associated with
  1. #1
    TomBarad is offline Junior Member
    Join Date
    Dec 2010
    Posts
    1

    Downloading Attachments to Fileserver with PHP

    Has anyone been able to use php to download attachments associated with a record in SF?

    Optimally, I would like the php to login, find a given record within the org, to create a directory on my fileserver using data from that record for the directory name, and then copy each attachment for the given record into that directory.

    I'm new here, but there have been many posts on logging in and finding a record. It's the directory creation and attachment copy/download that I'm trying to solve.

    Any help would be appreciated.

  2. #2
    Adam Best is offline Junior Member
    Join Date
    Apr 2011
    Posts
    10
    Hi Tom,

    I tried a few months ago without success either. We moved to AWS Objects (Amazon web services - S3). You install the app and create a lookup field on the AWS object record to your desired Standard Or Customer SalesForce Object such as customer, case etc... then you simply call on the table AWS_S3_Object__c and get your URL.

    You can upload AWS files via PHP as well. I'll post a link later today for full instructions.

    Regards,
    Adam
    Into Joomla! and SalesForce?
    Check us out below at
    miiWorks - SalesForce Apps, Joomla Extensions, Business Apps, Web Hosting, Domains
    Regards,
    Adam

    Into Joomla! and SalesForce?
    Check us out below at
    http://www.miiworks.com/

  3. #3
    Adam Best is offline Junior Member
    Join Date
    Apr 2011
    Posts
    10
    Hi Tom

    Here is the link to Install AWS Objects in your SalesForce CRM. This will allow you to upload and store files on any object via your SalesForce CRM.

    Installing Force for Amazon Web Services - developer.force.com


    To Upload files via your website, use the Amazon S3 PHP toolkit: Simply upload the file and then write the appropriate information to the AWS Object and desired relationships you've made.

    PHP Developer Center

    Here is some code I've got to upload 1 file with public access

    PHP Code:
            require_once ('/aws/sdk.class.php');
            require_once (
    '/aws/config.inc.php');
            
            
    header("Content-type: text/plain; charset=utf-8");
            
    $s3 = new AmazonS3();
            
    $bucket 'Yourbucketname';
            
    $fileloc 'thetempfilenameofyourfile';
            
    $filename 'yournewfilename.jpg';
            if(empty(
    $Option[ACL])){
                
    $Option[ACL]=AmazonS3::ACL_PUBLIC;
            }
            
    $exists $s3->if_bucket_exists($bucket);
            while (!
    $exists){sleep(1);$exists $s3->if_bucket_exists($bucket);}

            
    $s3->batch()->create_object($bucket$filename, array(
                
    'fileUpload' => $fileloc
                
    ,'acl'=>$Option[ACL]
                ,
    'contentType'=> 'image/jpeg'
            
    ));

            
    $file_upload_response $s3->batch()->send();
            if (
    $file_upload_response->areOK())
            {
                    
    $resp[Response]=$s3->get_object_url($bucket$filename'5 minutes') . PHP_EOL PHP_EOL;
                    echo 
    $resp[Response];
            }
            function 
    filter_file_list($arr)
            {
                return 
    array_values(array_filter(array_map('file_path'$arr)));
            }
            function 
    file_path($file)
            {
                return !
    is_dir($file) ? realpath($file) : null;
            } 
    Let me know if you require further assistance.

    Regards,
    Adam
    Into Joomla! and SalesForce?
    Check us out below at
    miiWorks - SalesForce Apps, Joomla Extensions, Business Apps, Web Hosting, Domains
    Regards,
    Adam

    Into Joomla! and SalesForce?
    Check us out below at
    http://www.miiworks.com/

+ Reply to Thread

Similar Threads

  1. Save attachments to contacts/leads
    By lachof in forum Salesforce PHP Tutorials
    Replies: 0
    Last Post: 02-25-2008, 11:46 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

SEO by vBSEO 3.5.2