(Unicode C++) Backblaze S3 Upload Binary
Demonstrates how to upload the in-memory binary data to an Backblaze bucket.
#include <CkHttpW.h>
#include <CkBinDataW.h>
#include <CkXmlW.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.
CkHttpW http;
// keyID = Access Key ID or Access Key
http.put_AwsAccessKey(L"access-key");
// applicationKey = Secret Access Key or Secret Key
http.put_AwsSecretKey(L"secret-key");
// Region is the 2nd part of your S3 Endpoint
http.put_AwsEndpoint(L"s3.us-west-002.backblazeb2.com");
const wchar_t *bucketName = L"chilkat-test-123";
const wchar_t *objectName = L"starfish.jpg";
// The Content-Type has the form type/subtype, such as application/pdf, application/json, image/jpeg, etc.
// See Explaining Content-Types
const wchar_t *contentType = L"image/jpeg";
http.put_KeepResponseBody(true);
CkBinDataW jpgData;
success = jpgData.LoadFile(L"qa_data/jpg/starfish.jpg");
success = http.S3_UploadBd(jpgData,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"JPG uploaded.\n");
}
}
|