Sample code for 30+ languages & platforms
C++

Backblaze S3 Upload Binary

See more Backblaze S3 Examples

Demonstrates how to upload the in-memory binary data to an Backblaze bucket.

Chilkat C++ Downloads

C++
#include <CkHttp.h>
#include <CkBinData.h>
#include <CkXml.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;

    //  keyID = Access Key ID or Access Key
    http.put_AwsAccessKey("access-key");

    //  applicationKey = Secret Access Key or Secret Key
    http.put_AwsSecretKey("secret-key");

    //  Region is the 2nd part of your S3 Endpoint
    http.put_AwsEndpoint("s3.us-west-002.backblazeb2.com");

    const char *bucketName = "chilkat-test-123";
    const char *objectName = "starfish.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";

    http.put_KeepResponseBody(true);

    CkBinData jpgData;
    success = jpgData.LoadFile("qa_data/jpg/starfish.jpg");

    success = http.S3_UploadBd(jpgData,contentType,bucketName,objectName);
    if (success != true) {
        std::cout << http.lastErrorText() << "\r\n";

        CkXml xml;
        xml.LoadXml(http.lastResponseBody());
        std::cout << xml.getXml() << "\r\n";
    }
    else {
        std::cout << "JPG uploaded." << "\r\n";
    }
    }