Sample code for 30+ languages & platforms
Dart

S3 Upload File

See more Amazon S3 Examples

Demonstrates how to upload a file to the Amazon S3 service.

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();

  // Insert your AWS keys here:
  http.awsAccessKey = 'AWS_ACCESS_KEY';
  http.awsSecretKey = 'AWS_SECRET_KEY';

  final bucketName = 'chilkat.ocean';
  final objectName = 'seahorse.jpg';
  final localFilePath = 'qa_data/jpg/seahorse.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';

  try {
    http.s3UploadFile(localFilePath, contentType, bucketName, objectName);
    print('File uploaded.');
  } on ChilkatException catch (e) {
    print(e.lastErrorText);
  }
}