Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server (Not)   Client   Old   Guides   Examples
New in version: 6.1   6.2   6.3   6.4   6.5   7.0   7.1   7.2   7.3   7.4    Statistic  

CURL.SetupAWS

Setup CURL to transfer to Amazon Webservices.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
CURL 7.2 Yes Yes Yes Yes Yes

MBS( "CURL.SetupAWS"; Handle; AWSAccessKeyId; AWSSecretAccessKey; Region; Service; Path; Domain; Verb { ; HashedPayload; Headers } )

Parameters

Parameter Description Example value
Handle 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 Optional
The hashed payload.
If empty, we calculate it automatically from input data or postfields.
This is a lowercase hex SHA256.
Headers Optional
Extra HTTP headers to include.
Here you can specify various headers to include in signature and request.
"x-amz-acl: public-read"

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.Cleanup"; $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:"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.Cleanup"; $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.Cleanup"; $curl) ]

See also

Example Databases


CURL.SetUpdateProgressDialog   -   CURL.UseSystemCertificates

Feedback: Report problem or ask question.




Links
MBS Xojo PDF Plugins