Sample code for 30+ languages & platforms
Dart

Backblaze S3 Upload Binary

See more Backblaze S3 Examples

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

Chilkat Dart Downloads

Dart
import 'package:chilkat/chilkat.dart';

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

  final http = CkHttp();

  // keyID = Access Key ID or Access Key
  http.awsAccessKey = 'access-key';

  // applicationKey = Secret Access Key or Secret Key
  http.awsSecretKey = 'secret-key';

  // Region is the 2nd part of your S3 Endpoint
  http.awsEndpoint = 's3.us-west-002.backblazeb2.com';

  final bucketName = 'chilkat-test-123';
  final objectName = 'starfish.jpg';

  // The Content-Type has the form  type/subtype, such as application/pdf, application/json, image/jpeg, etc.
  // See Explaining Content-Types
  final contentType = 'image/jpeg';

  http.keepResponseBody = true;

  final jpgData = CkBinData();
  jpgData.loadFile('qa_data/jpg/starfish.jpg');

  try {
    http.s3UploadBd(jpgData, contentType, bucketName, objectName);
    print('JPG uploaded.');
  } on ChilkatException catch (e) {
    print(e.lastErrorText);

    final xml = CkXml();
    xml.loadXml(http.lastResponseBody);
    print(xml.getXml());
  }
}