(Unicode C) Generate S3 Signed URL
Demonstrates how to generate a pre-signed S3 URL. Note: This example requires Chilkat v11.0.0 or greater.
#include <C_CkHttpW.h>
void ChilkatSample(void)
{
HCkHttpW http;
const wchar_t *bucketName;
const wchar_t *path;
const wchar_t *signedUrl;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttpW_Create();
// Insert your access key here:
CkHttpW_putAwsAccessKey(http,L"AWS_ACCESS_KEY");
// Insert your secret key here:
CkHttpW_putAwsSecretKey(http,L"AWS_SECRET_KEY");
CkHttpW_putAwsRegion(http,L"us-west-2");
CkHttpW_putAwsEndpoint(http,L"s3-us-west-2.amazonaws.com");
bucketName = L"chilkattest";
path = L"starfish.jpg";
signedUrl = CkHttpW_s3_GenPresignedUrl(http,L"GET",TRUE,bucketName,path,3600,L"s3");
if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
return;
}
wprintf(L"%s\n",signedUrl);
CkHttpW_Dispose(http);
}
|