(C) Generate S3 Signed URL
Demonstrates how to generate a pre-signed S3 URL.
#include <C_CkHttp.h>
#include <C_CkDateTime.h>
void ChilkatSample(void)
{
HCkHttp http;
const char *bucketName;
const char *path;
HCkDateTime expireTime;
const char *signedUrl;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttp_Create();
// Insert your access key here:
CkHttp_putAwsAccessKey(http,"AWS_ACCESS_KEY");
// Insert your secret key here:
CkHttp_putAwsSecretKey(http,"AWS_SECRET_KEY");
bucketName = "chilkattest";
path = "starfish.jpg";
expireTime = CkDateTime_Create();
CkDateTime_SetFromCurrentSystemTime(expireTime);
CkDateTime_AddSeconds(expireTime,3600);
signedUrl = CkHttp_s3_GenerateUrl(http,bucketName,path,expireTime);
if (CkHttp_getLastMethodSuccess(http) != TRUE) {
printf("%s\n",CkHttp_lastErrorText(http));
}
else {
printf("%s\n",signedUrl);
}
CkHttp_Dispose(http);
CkDateTime_Dispose(expireTime);
}
|