2 Replies Latest reply on May 10, 2017 1:00 PM by JFWX5

    Serverside script Curl to S3

    JFWX5

      Hi,

       

      Is it possible to create a script on FMS16 and use the Curl functions to upload files to S3?

       

      If so how would it be done?

       

      BTW I'm using OS X.

       

       

       

       

      Thanks

        • 1. Re: Serverside script Curl to S3
          Mike Duncan

          It would be easier to create a PHP script to handle the file upload and then post it to S3 from there. AWS has a PHP SDK that I've used before to handle html form uploads and put them in an S3 bucket, so your cURL from FM could post to a similar PHP script. That way authenticating to the service could be passed in as parameters or hard coded IAM credentials in your scripting.

          Otherwise, there is a bit of legwork to figure out the correct headers to send in order to authenticate to the AWS REST SDK, where you have to calculate an authorization string based on the checksum of the payload request and such.

           

          Hope that helps

          Mike

          1 of 1 people found this helpful
          • 2. Re: Serverside script Curl to S3
            JFWX5

            I'm not too up on the curl function

             

            but I found this on the web.

             

            date=`date +%Y%m%d`

            dateFormatted=`date -R`

            s3Bucket="BUCKET_OF_S3_SERVER"

            fileName="FILE_NAME"

            relativePath="/${s3Bucket}/${fileName}"

            contentType="application/octet-stream"

            stringToSign="PUT\n\n${contentType}\n${dateFormatted}\n${relativePath}"

            s3AccessKey="ACCESS_KEY_OF_S3_SERVER"

            s3SecretKey="SECRET_KEY_OF_S3_SERVER"

            signature=`echo -en ${stringToSign} | openssl sha1 -hmac ${s3SecretKey} -binary | base64`

            curl -X PUT -T "${fileName}" \

            -H "Host: ${s3Bucket}.s3.amazonaws.com" \

            -H "Date: ${dateFormatted}" \

            -H "Content-Type: ${contentType}" \

            -H "Authorization: AWS ${s3AccessKey}:${signature}" \

             

             

            Can this be added to a FileMaker script?

             

             

            Thanks