Dart
Dart
Wasabi Upload String
See more Wasabi Examples
Demonstrates how to upload the contents of a string to create an object in a Wasabi bucket.Chilkat Dart Downloads
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();
// Insert your access key here:
http.awsAccessKey = 'access-key';
// Insert your secret key here:
http.awsSecretKey = 'secret-key';
http.awsEndpoint = 's3.wasabisys.com';
final bucketName = 'chilkattest';
final objectName = 'orchard.json';
final contentType = 'application/json';
http.keepResponseBody = true;
// Let's say we have JSON in a string and want to upload it to a file in Wasabi..
final jsonStr = '{ "orchard": "apple" }';
// The charset indicates the byte representation of what is uploaded.
// If needed, Chilkat will internally convert to the desired byte representation before uploading.
final charset = 'utf-8';
try {
http.s3UploadString(jsonStr, charset, contentType, bucketName, objectName);
print('String uploaded.');
} on ChilkatException catch (e) {
print(e.lastErrorText);
final xml = CkXml();
xml.loadXml(http.lastResponseBody);
print(xml.getXml());
}
}