(C++) S3 Upload File
Demonstrates how to upload a file to the Amazon S3 service.
#include <CkHttp.h>
void ChilkatSample(void)
{
bool success = false;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkHttp http;
// Insert your AWS keys here:
http.put_AwsAccessKey("AWS_ACCESS_KEY");
http.put_AwsSecretKey("AWS_SECRET_KEY");
const char *bucketName = "chilkat.ocean";
const char *objectName = "seahorse.jpg";
const char *localFilePath = "qa_data/jpg/seahorse.jpg";
// The Content-Type has the form type/subtype, such as application/pdf, application/json, image/jpeg, etc.
// See Explaining Content-Types
const char *contentType = "image/jpeg";
success = http.S3_UploadFile(localFilePath,contentType,bucketName,objectName);
if (success != true) {
std::cout << http.lastErrorText() << "\r\n";
}
else {
std::cout << "File uploaded." << "\r\n";
}
}
|