amazon_s3_cognito 0.8.1 copy "amazon_s3_cognito: ^0.8.1" to clipboard
amazon_s3_cognito: ^0.8.1 copied to clipboard

This plugin allows users to upload and delete image for amazon s3 cognito.Users can also upload multiple images ti s3 using the plugin.

amazon_s3_cognito #

Amazon S3 plugin for Flutter

Unofficial Amazon S3 plugin written in Dart for Flutter.

Plugin in maintained by fäm

Usage #

To use this plugin, add amazon_s3_cognito as a dependency in your pubspec.yaml file.

The package is android-x compatible
  amazon_s3_cognito: '^0.7.9'

Example #

import 'package:amazon_s3_cognito/amazon_s3_cognito.dart';
import 'package:amazon_s3_cognito/aws_region.dart';

//Use the below code to specify the region and sub region for image upload
//Also this method allows to upload all file type including images and pdf etc.

//imageData - this object will contain file details, like file name, file path, folder where to upload file inside bucket etc..
//construct imagedata object
ImageData imageData = ImageData("uniqueFileName", filePath,
        uniqueId: "uniqueIdToTrackImage", imageUploadFolder: "folder to upload inside bucket");

//call AWS to upload file
//needMultipartUpload - only applicable for IOS, when your uploads are so large that they take more than 1 hour to complete set its value to true
String uploadedImageUrl = await AmazonS3Cognito.upload(String bucket, String identity, String region,
                  String subRegion, ImageData imageData,
                  {bool needMultipartUpload = false})

//Please Note: In bucket name only send bucket name. If you will include subfolder in it, the upload will fail
//Example : if we want image to upload in bucket BUCKET_TEST, and inside that bucket we want to upload image into
// MANAGEMENT folder, then in bucket name send only BUCKET_TEST and in ImageData.imageUploadFolder send MANAGEMENT
//other wise the upload will not work.

//we can now also upload multiple images via list and listener to its progress
//and upload changes via stream.

//create an event channel

  EventChannel _amazonS3Stream =
  StreamSubscription? uploadListenerSubscription;

  //call _listenToFileUpload() in initstate method or when you want to
  //start listeneing to image upload
  //steeams pass back hashmap, as passing custom object is not supported yet
  //we can covert map to object in stream like below.

   void _listenToFileUpload() {
      //when you want to upload multi-files or listen to upload then
      //you get the image progress via this stream
      uploadListenerSubscription =
          _amazonS3Stream.receiveBroadcastStream().listen((event) {
        LinkedHashMap<Object?, Object?> map = event;
        ImageData imageData = ImageData.fromMap(map);
        //update the ui based on the object returned in stream

    //cancel subcrition of stream when you are done
    void dispose() {

    //use multiple image upload method
          String bucket,
          String identity,
          String region,
          String subRegion,
          List<ImageData> imageData,
          bool needProgressUpdateAlso,
          {bool needMultipartUpload = false})

//use below code to delete an image
 String result = await AmazonS3Cognito.delete(
                       String bucket,
                       String identity,
                       String imageName,
                       String? folderInBucketWhereImgIsUploaded,
                       String region,
                       String subRegion)



Installation #

Android #

Inside AndroidManifest.xml register TransferService like below

 <service android:name= "com.amazonaws.mobileconnectors.s3.transferutility.TransferService" android:enabled="true" />

iOS #

inside your Appdelegate add following method

func application(_ application: UIApplication, handleEventsForBackgroundURLSession identifier: String, completionHandler: @escaping () -> Void) {
    // Store the completion handler.
    AWSS3TransferUtility.interceptApplication(application, handleEventsForBackgroundURLSession: identifier, completionHandler: completionHandler)

for documentation further read

Authors #

the plugin is created and maintained by fäm properties. 
Android version written by Prachi Shrivastava
IOS version written by Prachi Shrivastava
pub points


unverified uploader

This plugin allows users to upload and delete image for amazon s3 cognito.Users can also upload multiple images ti s3 using the plugin.

Repository (GitHub)
View/report issues


API reference






Packages that depend on amazon_s3_cognito