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:
9.3
9.4
9.5
10.0
10.1
10.2
10.3
10.4
10.5
10.6
Statistic
FMM
Blog
CURL.SetupAWS
Setup CURL to transfer to Amazon Webservices.
| Component | Version | macOS | Windows | Linux | Server | FileMaker 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 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. |
"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 and pass it here as parameter.
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.GetDebugAsText"; $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.GetDebugAsText"; $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.GetDebugAsText"; $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.GetDebugAsText"; $curl) ]
Set Variable [ $result ; Value: MBS("CURL.Release"; $curl) ]
See also
- CURL.GetDebugAsText
- CURL.GetResultAsJPEG
- CURL.New
- CURL.OpenInputFile
- CURL.Perform
- CURL.Release
- CURL.SetDebugWithData
- CURL.SetInputFile
- CURL.SetInputPDF
- Hash.Digest
Example Databases
- CURL/Amazon S3 Buckets
- CURL/Amazon S3 Download Picture
- CURL/Amazon S3 Upload File
- CURL/Amazon S3 Upload Picture
Blog Entries
- MBS FileMaker Plugin, version 8.2pr3
- MBS FileMaker Plugin v8.1 with 5100 Functions In One Plugin
- MBS FileMaker Plugin 8.1
- MBS FileMaker Plugin, version 8.1pr3
- MBS FileMaker Plugin, version 8.0pr7
- Amazon S3 Upload with Mime Type and Permissions
- MBS FileMaker Plugin 7.2
Release notes
- 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.
Created 22nd March 2017, last changed 19th April 2020
CURL.SetUpdateProgressDialog - CURL.SetupOAuth
Feedback: Report problem or ask question.
Links
MBS Xojo Plugins