Topics
All
MacOS
(Only)
Windows
(Only)
Linux
(Only, Not)
iOS
(Only, Not)
Components
Crossplatform Mac & Win
Server
Client
Old
Deprecated
Guides
Examples
Videos
New in version:
12.1
12.2
12.3
12.4
12.5
13.0
13.1
13.2
13.3
13.4
Statistic
FMM
Blog
Setup CURL to transfer to Amazon Webservices.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
CURL | 7.2 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameter | Description | Example | Flags |
---|---|---|---|
curl | The CURL session handle. | $curl | |
AWSAccessKeyId | Your access key for AWS. | ||
AWSSecretAccessKey | Your secret. | ||
Region | The region to use. | "eu-central-1" | |
Service | The service to use. | "s3" | |
Path | The path for the URL. Should always start with "/". |
"/bucketname/test.jpg" | |
Domain | Optional the domain to use. By default we just build it from region and service. |
"s3.eu-central-1.amazonaws.com" or "s3-ap-southeast-2.amazonaws.com" | |
Verb | The HTTP Operation to do. Can be POST, PUT, GET, PATCH, HEAD or DELETE. |
"PUT" | |
HashedPayload | The hashed payload. If empty, we calculate it automatically from input data or postfields. This is a lowercase hex SHA256. |
Optional | |
Headers | Extra HTTP headers to include. Here you can specify various headers to include in signature and request. |
"x-amz-acl: public-read" | Optional |
QueryParameters | Available in MBS FileMaker Plugin 8.4 or newer. List of query parameters to include. Keys and values must be URL encoded using Text.EncodeURLComponent. Keys may need to be lowercase. |
"id=123¶test=abc" | Optional |
Returns OK or error.
Download via S3:
Set Variable [$AWSAccessKeyId; Value:"xxx"]
Set Variable [$AWSSecretAccessKey; Value:"yyy"]
Set Variable [$Region; Value:"eu-central-1"]
Set Variable [$Bucketname; Value:"zzz"]
Set Variable [$Filename; Value:"test.jpg"]
Set Variable [$Verb; Value:"GET"]
Set Variable [$Service; Value:"s3"]
#Keep those empty for default
Set Variable [$Domain; Value:""]
Set Variable [$HashedPayload; Value:""]
#Build a path
Set Variable [$Path; Value:"/" & $BucketName & "/" & $Filename]
#
Set Variable [$curl; Value:MBS("CURL.New")]
Set Variable [$result; Value:MBS("CURL.SetupAWS"; $curl; $AWSAccessKeyId; $AWSSecretAccessKey; $Region; $Service; $Path; $Domain; $Verb)]
Set Variable [$result; Value:MBS("CURL.SetDebugWithData"; $curl; 1)]
Set Field [CURL Test::Result; MBS("CURL.Perform"; $curl)]
Set Field [CURL Test::Image; MBS("CURL.GetResultAsJPEG"; $curl)]
Set Field [CURL Test::debug; MBS("CURL.GetDebugMessages"; $curl)]
Set Variable [$result; Value:MBS("CURL.Release"; $curl)]
Upload to S3:
Set Variable [$AWSAccessKeyId; Value:"xxx"]
Set Variable [$AWSSecretAccessKey; Value:"xxx"]
Set Variable [$Region; Value:"us-east-1"]
Set Variable [$Bucketname; Value:"xxx"]
Set Variable [$Filename; Value:"test.jpg"]
Set Variable [$Service; Value:"s3"]
# do upload
Set Variable [$Verb; Value:"PUT"]
# make file available to public
Set Variable [ $Headers ; Value: "Content-Type: image/jpeg¶x-amz-acl: public-read" ]
#Keep those empty for default
Set Variable [$Domain; Value:""]
Set Variable [$HashedPayload; Value:""]
#Build a path
Set Variable [$Path; Value:"/" & $BucketName & "/" & $Filename]
#
Set Variable [$curl; Value:MBS("CURL.New")]
# pass in container
Set Variable [$result; Value:MBS("CURL.SetInputFile"; $curl; CURL Test::Image)]
#
Set Variable [$result; Value:MBS("CURL.SetupAWS"; $curl; $AWSAccessKeyId; $AWSSecretAccessKey; $Region; $Service; $Path; $Domain; $Verb; ""; $Headers)]
Set Field [CURL Test::Result; MBS("CURL.Perform"; $curl)]
Set Field [CURL Test::debug; MBS("CURL.GetDebugMessages"; $curl)]
Set Field [CURL Test::resultText; MBS("CURL.GetResultAsText"; $curl)]
Set Variable [$result; Value:MBS("CURL.Release"; $curl)]
Upload PDF from container:
Set Variable [ $curl ; Value: MBS("CURL.New") ]
Set Variable [ $result ; Value: MBS("CURL.SetInputPDF"; $curl; Documents::PDFContainer) ]
Set Variable [ $result ; Value: MBS("CURL.SetupAWS"; $curl; $AWSAccessKeyId; $AWSSecretAccessKey; $Region; $Service; $Path; $Domain; $Verb; ""; $headers) ]
Set Field [ CURL Test::Result ; MBS("CURL.Perform"; $curl) ]
Set Field [ CURL Test::debug ; MBS("CURL.GetDebugMessages"; $curl) ]
Set Variable [ $result ; Value: MBS("CURL.Release"; $curl) ]
Upload file from disk and calculate hash ourselves:
# Build a path to file (local) and in AWS
Set Variable [ $Filename ; Value: "test.pdf" ]
Set Variable [ $Path ; Value: "/" & $BucketName & "/PDF/" & $Filename ]
Set Variable [ $localPath ; Value: "/Users/cs/Desktop/license.pdf" ]
# calculate hash for file to upload
Set Variable [ $HashedPayload ; Value: Lower(MBS( "Hash.Digest"; "sha256"; "path"; $localPath; ""; "hex" )) ]
# upload
Set Variable [ $curl ; Value: MBS("CURL.New") ]
# file content is streamed
Set Variable [ $result ; Value: MBS("CURL.OpenInputFile"; $curl; $localPath) ]
# setup AWS
Set Variable [ $result ; Value: MBS("CURL.SetupAWS"; $curl; $AWSAccessKeyId; $AWSSecretAccessKey; $Region; $Service; $Path; $Domain; $Verb; $HashedPayload; $headers) ]
Set Field [ CURL Test::Result ; MBS("CURL.Perform"; $curl) ]
Set Field [ CURL Test::debug ; MBS("CURL.GetDebugMessages"; $curl) ]
Set Variable [ $result ; Value: MBS("CURL.Release"; $curl) ]
Upload to S3 with transfer acceleration:
// transfer acceleration must be enabled for the bucket.
// while region is not needed for the URL, it is still going into security checksums.
Set Variable [$AWSAccessKeyId; Value:"xxx"]
Set Variable [$AWSSecretAccessKey; Value:"xxx"]
Set Variable [$Region; Value:"us-east-1"]
Set Variable [$Bucketname; Value:"xxx"]
Set Variable [$Filename; Value:"test.jpg"]
Set Variable [$Service; Value:"s3"]
# do upload
Set Variable [$Verb; Value:"PUT"]
# make file available to public
Set Variable [ $Headers ; Value: "Content-Type: image/jpeg¶x-amz-acl: public-read" ]
#Keep those empty for default
Set Variable [$Domain; Value: $BucketName & ".s3-accelerate.amazonaws.com"]
Set Variable [$HashedPayload; Value:""]
#Build a path
Set Variable [$Path; Value:"/" & $Filename]
#
Set Variable [$curl; Value:MBS("CURL.New")]
# pass in container
Set Variable [$result; Value:MBS("CURL.SetInputFile"; $curl; CURL Test::Image)]
#
Set Variable [$result; Value:MBS("CURL.SetupAWS"; $curl; $AWSAccessKeyId; $AWSSecretAccessKey; $Region; $Service; $Path; $Domain; $Verb; ""; $Headers)]
Set Field [CURL Test::Result; MBS("CURL.Perform"; $curl)]
Set Field [CURL Test::debug; MBS("CURL.GetDebugMessages"; $curl)]
Set Field [CURL Test::resultText; MBS("CURL.GetResultAsText"; $curl)]
Set Variable [$result; Value:MBS("CURL.Release"; $curl)]
This function checks for a license.
Created 22nd March 2017, last changed 3th March 2023