Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
CURL.SetupAWS
Setup CURL to transfer to Amazon Webservices.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
CURL | 7.2 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameters
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 |
Result
Returns OK or error.
Description
Setup CURL to transfer to Amazon Webservices.This implements AWS4-HMAC-SHA256 signature for credentials, sets authentication, URL, HTTP Headers and other parameters.
For upload or post, please set input parameters first.
When using CURL.OpenInputFile to stream data, you need to calculate the payload hash yourself (with Hash.Digest) and pass it here as parameter.
Works also for other compatible S3 services beside Amazon's like the one from Wasabi or Dell ECS.
Please be aware that this function depends on a correct time and date set on the computer. If the time is not set correct, the authentication will fail.
Examples
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)]
See also
- CURL.GetResultAsJPEG
- CURL.GetResultAsText
- CURL.New
- CURL.OpenInputFile
- CURL.Perform
- CURL.SetDebugWithData
- CURL.SetInputFile
- CURL.SetInputPDF
- Hash.Digest
- Text.EncodeURLComponent
Release notes
- Version 14.0
- Fixed CURL.SetupAWS and CURL.SetupOAuth to reset NoBody flag if new transfer is not head.
- Version 13.0
- Add PATCH support for CURL.SetupAWS function.
- Version 11.4
- Added HEAD as verb for CURL.SetupAWS and CURL.SetupOAuth functions.
- Fixed an issue with CURL.SetupAWS doing an unneeded lower case for the query parameter name.
- Version 8.4
- Added new query parameter for CURL.SetupAWS function.
- Version 8.2
- Changed CURL.SetupAWS to no longer complain for empty path string as this is needed for AWS Translate.
- Version 8.1
- Improved CURL.SetupAWS method to work better with Amazon S3 and also with Dell ECS.
- Version 8.0
- Fixed bug in CURL.SetupAWS when wrong date was used.
Example Databases
- CURL/Amazon S3/Amazon S3 Buckets
- CURL/Amazon S3/Amazon S3 Download Picture
- CURL/Amazon S3/Amazon S3 Upload File
- CURL/Amazon S3/Amazon S3 Upload Picture
- CURL/Amazon S3/Containers in S3
Blog Entries
- MBS FileMaker Plugin, version 13.6pr1
- MBS Plugin 13.0 for Claris FileMaker
- MBS FileMaker Plugin, version 12.6pr1
- MBS FileMaker Plugin 11.4 - More than 6500 Functions In One Plugin
- MBS FileMaker Plugin, version 11.4pr2
- MBS FileMaker Plugin 11.1
- MBS FileMaker Plugin v8.1 with 5100 Functions In One Plugin
- MBS FileMaker Plugin 8.1
- Amazon S3 Upload with Mime Type and Permissions
- MBS FileMaker Plugin 7.2
This function checks for a license.
Created 22nd March 2017, last changed 3th March 2023