Sample code for 30+ languages & platforms
Unicode C

Backblaze S3 Upload Binary

See more Backblaze S3 Examples

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

Chilkat Unicode C Downloads

Unicode C
#include <C_CkHttpW.h>
#include <C_CkBinDataW.h>
#include <C_CkXmlW.h>

void ChilkatSample(void)
    {
    BOOL success;
    HCkHttpW http;
    const wchar_t *bucketName;
    const wchar_t *objectName;
    const wchar_t *contentType;
    HCkBinDataW jpgData;
    HCkXmlW xml;

    success = FALSE;

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    http = CkHttpW_Create();

    // keyID = Access Key ID or Access Key
    CkHttpW_putAwsAccessKey(http,L"access-key");

    // applicationKey = Secret Access Key or Secret Key
    CkHttpW_putAwsSecretKey(http,L"secret-key");

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

    bucketName = L"chilkat-test-123";
    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
    contentType = L"image/jpeg";

    CkHttpW_putKeepResponseBody(http,TRUE);

    jpgData = CkBinDataW_Create();
    success = CkBinDataW_LoadFile(jpgData,L"qa_data/jpg/starfish.jpg");

    success = CkHttpW_S3_UploadBd(http,jpgData,contentType,bucketName,objectName);
    if (success != TRUE) {
        wprintf(L"%s\n",CkHttpW_lastErrorText(http));

        xml = CkXmlW_Create();
        CkXmlW_LoadXml(xml,CkHttpW_lastResponseBody(http));
        wprintf(L"%s\n",CkXmlW_getXml(xml));
    }
    else {
        wprintf(L"JPG uploaded.\n");
    }



    CkHttpW_Dispose(http);
    CkBinDataW_Dispose(jpgData);
    CkXmlW_Dispose(xml);

    }