(Unicode C++) Wasabi Upload File
Demonstrates how to upload a file to a Wasabi bucket.
#include <CkHttpW.h>
#include <CkXmlW.h>
void ChilkatSample(void)
{
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkHttpW http;
// Insert your access key here:
http.put_AwsAccessKey(L"access-key");
// Insert your secret key here:
http.put_AwsSecretKey(L"secret-key");
http.put_AwsEndpoint(L"s3.wasabisys.com");
const wchar_t *bucketName = L"chilkattest";
const wchar_t *objectName = L"seahorse.jpg";
const wchar_t *localFilePath = L"qa_data/jpg/seahorse.jpg";
const wchar_t *contentType = L"image/jpg";
http.put_KeepResponseBody(true);
bool success = http.S3_UploadFile(localFilePath,contentType,bucketName,objectName);
if (success != true) {
wprintf(L"%s\n",http.lastErrorText());
CkXmlW xml;
xml.LoadXml(http.lastResponseBody());
wprintf(L"%s\n",xml.getXml());
}
else {
wprintf(L"File uploaded.\n");
}
}
|