All you need is a 5 line script.

You tell s3.fm where your container is, where you want it to go and what you want to do once it’s there and we take care of the rest. Here’s a step by step process for manually creating an upload request script.

First script step: store your s3.fm API key as a the $apikey variable.

An s3.fm API key will be sent to you after your register. This is your authentication for AWS, s3.fm, and if you’ve stored them with us, your FileMaker database.

Set Variable [$apikey; Value: "S3FM-XXXXXXXXXX-XXXX-XXX-XXX"]

Second script step: store s3.fm’s URL as a the $url variable.

FileMaker needs to know where s3.fm’s code is so we can do the heavy lifting for you. Our code lives on AWS, right next to where your container data is going.

Set Variable [$url; Value: "https://fm1casf962.execute-api.us-east-1.amazonaws.com/v1/s3fm_upload"]

Third script step: set a $payload variable.

s3.fm needs to know where your data is, where to put it and what to do after it’s there. So, we set a variable with a JSON expression that has all the parameters needed.*

Set Variable [$payload; Value: 
JSONSetElement ( "" ;
[ "fm.FQDN" ; "myserver.domain.com" ; 1 ] ;
[ "fm.database.name" ; Get ( FileName ) ; 1 ] ;
[ "fm.return.url.field" ; "uploadedURL" ; 1 ] ;
[ "fm.container.field" ; "image" ; 1 ] ;
[ "fm.container.layout" ; "imagesLayout" ; 1 ] ;
[ "fm.container.key.field" ; "imageID" ; 1 ] ;
[ "fm.container.key.value" ; Media::imageID ; 1 ] ;
[ "s3.bucket" ; "s3-fm-sandbox" ; 1 ] ;
[ "s3.key" ; "myImages/" & Media::MediaID & "/" & imagesLayout::filename ; 1 ] ;
[ "s3.makePublic" ; True ; 5 ] ;
[ "s3.region" ; "us-east-1" ; 1 ] 
; [ "fm.database.auth" ; "awhgi0a0283ww9803q2htyq9fn9q234oju" ; 1 ] ;
[ "fm.return.log.field" ; "uploadJSON" ; 1 ] ;
[ "fm.return.log.layout" ; "uploadRequestLoggingLayout" ; 1 ] ;
[ "fm.return.url.layout" ; "imagesLayout" ; 1 ] ;
[ "fm.return.url.key.field" ; "imageID" ; 1 ] ;
[ "fm.return.url.key.value" ; Media::imageID ; 1 ] ;
[ "fm.script.layout" ; "imagesLayout" ; 1 ] ;
[ "fm.script.name" ; "myScript" ; 1 ] ;
[ "fm.script.parameter" ; "scriptParameter" ; 1 ] 
)

*Required parameters are in bold, optional parameters are in plain text. For more details about each parameter, click here.

Fourth script step: add $apikey and $payload together as $curl.

Set Variable [$url; Value: "-X POST
-H \"X-API-Key: " & $apikey & "\"
-H \"Content-Type: application/json\"
--data-raw " & $payload

Final script step: Execute as Insert from URL.

Pick a destination field to show you any error or success messages (we used the “uploadedURL” field).

Insert from URL [Select; With dialog:Off; Target:Media::UploadedURL; $url; cURL options:$curl]