aws_uploader 0.0.1 copy "aws_uploader: ^0.0.1" to clipboard
aws_uploader: ^0.0.1 copied to clipboard

A Flutter plugin to upload images/files to AWS S3 using Cognito token-based authentication. Supports progress events and cancellation.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:aws_uploader/aws_uploader.dart';
import 'package:image_picker/image_picker.dart';

void main() => runApp(const MyApp());

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  double progress = 0;
  String status = '';

  @override
  void initState() {
    super.initState();
    AwsUploader.progressStream.listen((event) {
      setState(() {
        progress = (event['progress'] ?? 0).toDouble();
        status = event['status'] ?? '';
      });
      debugPrint('Event: $event');
    });
  }

  Future<void> uploadImage() async {
    final ImagePicker picker = ImagePicker();
    final XFile? image = await picker.pickImage(source: ImageSource.gallery);
    if (image == null) return;

    final url = await AwsUploader.startImgUpload(
      uploadId: '1',
      awsToken: 'AWS TOKEN GENERATED BY YOUR BACKEND',
      identityId: 'AWS IDENTITY ID GENERATED BY YOUR BACKEND',
      bucketName: 'BUCKET NAME',
      filePath: image.path,
      fileName: image.name,
      imageUploadFolder: 'stage/testing',
      identityPoolId: 'AWS IDENTITY POOL ID FROM AWS CONSOLE',
      providerName: 'PROVIDER NAME FROM AWS CONSOLE',
      region: 'YOUR BUCKET REGION',
    );

    debugPrint("UPLOADED IMAGE URL:::::::::::::::: $url");
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('AWS Uploader Plugin Test')),
        body: Padding(
          padding: const EdgeInsets.all(20),
          child: Column(
            children: [
              ElevatedButton(
                onPressed: uploadImage,
                child: const Text('Start Upload'),
              ),
              const SizedBox(height: 20),
              LinearProgressIndicator(value: progress / 100),
              const SizedBox(height: 10),
              Text('Progress: ${progress.toStringAsFixed(2)}%'),
              Text('Status: $status'),
            ],
          ),
        ),
      ),
    );
  }
}
2
likes
150
points
122
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin to upload images/files to AWS S3 using Cognito token-based authentication. Supports progress events and cancellation.

Repository (GitHub)
View/report issues

Documentation

API reference

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on aws_uploader

Packages that implement aws_uploader