Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

CURL.AWSPresignURL

Query predigend URL for Amazon Webservices.

Component Version macOS Windows Linux Server iOS SDK
CURL 11.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "CURL.AWSPresignURL"; AWSAccessKeyId; AWSSecretAccessKey; Region; Service; Path; Domain { ; Verb; Expires; QueryParameters; Headers } )   More

Parameters

Parameter Description Example Flags
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.
Default is GET.
"GET" Optional
Expires Expiration duration.
Provides the time period, in seconds, for which the generated presigned URL is valid. For example, 86400 (24 hours). This value is an integer. The minimum value you can set is 1, and the maximum is 604800 (seven days).
A presigned URL can be valid for a maximum of seven days because the signing key you use in signature calculation is valid for up to seven days.

Default is 86400 for one day.
Optional
QueryParameters List of query parameters to include.
Keys and values must be URL encoded.
Keys may need to be lowercase.
"id=123¶test=abc" Optional
Headers Extra HTTP headers to include.
Here you can specify various headers to include in signature and request.
Optional

Result

Returns URL or error.

Description

Query predigend URL for Amazon Webservices.
This implements AWS4-HMAC-SHA256 pre-signature for credentials.

Works also for other compatible S3 services beside Amazon's like the one from Wasabi or Dell ECS.

Examples

Try it for a S3 request:

MBS( "CURL.AWSPresignURL";
"AKIAIOSFODNN7EXAMPLE";
"wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY";
"us-east-1";
"s3";
"/test.txt";
"examplebucket.s3.amazonaws.com";
"GET";
86400 )

Example result: https://examplebucket.s3.amazonaws.com/test.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIOSFODNN7EXAMPLE/20210624/us-east-1/s3/aws4_request&X-Amz-Date=20210624T153735Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=216f12a0121da9fd2b5c87e68cfbbfe79331cb65aab3b989879a25042f5e1511

Build an URL and use it:

# our parameters
Set Variable [ $AWSAccessKeyId ; Value: "AKIAXYQWFBIBSX2I6GEA" ]
Set Variable [ $AWSSecretAccessKey ; Value: "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" ]
Set Variable [ $Region ; Value: "eu-central-1" ]
Set Variable [ $Bucketname ; Value: "monkeybreadsoftware" ]
Set Variable [ $Filename ; Value: "test.jpg" ]
Set Variable [ $Verb ; Value: "GET" ]
Set Variable [ $Service ; Value: "s3" ]
# Keep domain empty for default, which is service concatted by region
Set Variable [ $Domain ; Value: "" ]
# Build a path
Set Variable [ $Path ; Value: "/" & $BucketName & "/" & $Filename ]
# and get the URL
Set Variable [ $URL ; Value: MBS( "CURL.AWSPresignURL"; $AWSAccessKeyId; $AWSSecretAccessKey; $Region; $Service; $Path; $Domain; $Verb ) ]
# try it
Set Variable [ $curl ; Value: MBS("CURL.New") ]
Set Variable [ $result ; Value: MBS("CURL.SetOptionURL"; $curl; $URL) ]
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) ]

See also

Release notes

Example Databases

Blog Entries

This function checks for a license.

Created 24th June 2021, last changed 3th January 2023


CUPS.PrintFile - CURL.AddInputFile