搜索插件、代码仓与 APP 分类

插件详情v0.3.2

simple_s3

一个功能强大但易于使用的 AWS S3 插件,可在 Android 和 iOS 上上传和删除任意文件。

AndroidiOS
近 30 天下载
108
喜欢数
41
Pub 分数
140

安装插件

flutter pub add simple_s3

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

simple_s3 是一个 Flutter 插件,可简化在 Android 和 iOS 上上传和删除 AWS S3 文件的操作。该插件以易用性为核心设计,将复杂的 AWS SDK 操作抽象为简单的方法,使开发者无需深入了解 AWS 即可管理文件存储。该包支持任意文件类型,并可无缝集成到需要云文件处理的移动应用中。它利用 AWS 安全的身份验证机制,同时保持轻量级且对开发者友好的 API。

适合场景

  • 将图像和文档上传到 AWS S3
  • 从 S3 存储桶中删除文件
  • 在移动应用中集成云存储
  • 处理用户生成内容的存储
  • 启用备份和同步功能

主要特点

  • 简单的上传和删除API
  • 支持所有文件类型
  • 安全的 AWS S3 集成
  • 跨平台兼容性(Android 和 iOS)
  • 最小化设置和配置

适合对象

  • 使用 AWS S3 的移动应用开发人员
  • 需要文件上传/删除功能的项目
  • 需要安全云文件管理的应用程序
  • 寻求轻量级 S3 解决方案的开发者

使用建议

  • 需要 AWS 凭据和正确的存储桶策略
  • 仅限 Android 和 iOS 平台
  • 依赖外部 AWS SDK 的行为
  • 无内置文件列表或元数据管理

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

simple_s3

An advance yet simple to use AWS S3 plugin for upload and deletion.

Simple S3 uses AWS Native SDKs for iOS and Android

Getting started

Add dependency in pubspec.yaml

simple_s3: 0.3.2

Follow @ab_hi_j on Twitter

Features

Feature Description
Null Safe :white_check_mark:
Upload Percentage :white_check_mark:
Supports all files SimpleS3 auto detects content type of file by looking into extension
Set Access Type Allows you to set access type of file ex. PublicRead, Private etc
Default is Public Read
Timestamp Turned off by default if turned on allows you to append timestamp in file name.
Location of timestamp can be changed to either prefix or suffix
Default is prefix
Custom File Name Allows to change name of file about to upload.
Note : File name must contain extension.
Custom S3 folder path Allows to upload file to specific folder in S3
Sub Region Support Allows upload/delete operations on S3 having sub regions
Delete Object Allows deletion of file object
Auto Generates URL URL pointing to S3 file is auto generated.


Not working in Android Release mode ?

If your Android app is not working in release mode please check this section


Usage Examples

Simple File Upload

// returns url pointing to S3 file

SimpleS3 _simpleS3 = SimpleS3();
String result = await _simpleS3.uploadFile(
				file, <--------------- Selected File
				bucketName, <--------- Your Bucket Name
				poolID, <------------- Your POOL ID
				AWSRegions.apSouth1 <- S3 server region
				);

Delete

// returns bool

bool result = await SimpleS3.delete(
				filePath, <---------------- S3 File Path
				bucketName, <-------------- Your Bucket Name
				poolID, <------------------ Your POOL ID
				AWSRegions.apSouth1, <----- S3 server region
				);

// delete also supports sub-regions

File Upload with Percentage

// returns url pointing to S3 file

SimpleS3 _simpleS3 = SimpleS3();
//Upload function
String result = await _simpleS3.uploadFile(
				file, <--------------- Selected File
				bucketName, <--------- Your Bucket Name
				poolID, <------------- Your POOL ID
				AWSRegions.apSouth1 <- S3 server region
				);

//Widget
child: StreamBuilder<dynamic>(  
    stream: _simpleS3.getUploadPercentage,  
    builder: (context, snapshot) {  
      return new Text(  
        snapshot.data != null ? "Uploaded: ${snapshot.data}" : "Simple S3",  
    );  
  }),

Custom File Name

// returns url pointing to S3 file

SimpleS3 _simpleS3 = SimpleS3();
String result = await _simpleS3.uploadFile(
				file, <------------------------------ Selected File
				bucketName, <------------------------ Your Bucket Name
				poolID, <---------------------------- Your POOL ID
				AWSRegions.apSouth1, <--------------- S3 server region
				fileName: "Dennis_ritchie.jpeg", <--- Custom file name
				);

Custom S3 Path

// returns url pointing to S3 file

SimpleS3 _simpleS3 = SimpleS3();
String result = await _simpleS3.uploadFile(
				file, <-------------------------------- Selected File
				bucketName, <--------------------------- Your Bucket Name
				poolID, <------------------------------- Your POOL ID
				AWSRegions.apSouth1, <------------------ S3 server region
				s3FolderPath: "users/profile_pics", <--- Custom S3 path
				);

// final path will be  "bucketName/users/profile_pics"

Setting Access Control

// returns url pointing to S3 file

SimpleS3 _simpleS3 = SimpleS3();
String result = await _simpleS3.uploadFile(
				file, <------------------------------------- Selected File
				bucketName, <------------------------------- Your Bucket Name
				poolID, <----------------------------------- Your POOL ID
				AWSRegions.apSouth1, <---------------------- S3 server region
				accessControl: S3AccessControl.private, <--- Setting access of uploaded file **private**
				);

// S3AccessControl have more types of AccessControl ex. .publicRead, .publicReadWrite etc...

Using Timestamp

// returns url pointing to S3 file

SimpleS3 _simpleS3 = SimpleS3();
String result = await _simpleS3.uploadFile(
				file, <------------------------------------- Selected File
				bucketName, <------------------------------- Your Bucket Name
				poolID, <----------------------------------- Your POOL ID
				AWSRegions.apSouth1, <---------------------- S3 server region
				useTimeStamp: true, <----------------------- Enable Timestamp
				);

// default location of timestamp is prefix
// if original file name = "Dennis_ritchie.jpeg"
// then the result will be = "1591705658_Dennis_ritchie.jpeg"


// Change Timestamp Location



SimpleS3 _simpleS3 = SimpleS3();
String result = await _simpleS3.uploadFile(
				file, <--------------------------------------- Selected File
				bucketName, <--------------------------------- Your Bucket Name
				poolID, <------------------------------------- Your POOL ID
				AWSRegions.apSouth1, <------------------------ S3 server region
				useTimeStamp: true, <------------------------- Enable Timestamp
				timeStampLocation: TimestampLocation.suffix,<- Changes timestamp location to suffix
				);
// if original file name = "Dennis_ritchie.jpeg"
// then the result will be = "Dennis_ritchie_1591705658.jpeg"

Using Sub-Region

// returns url pointing to S3 file

SimpleS3 _simpleS3 = SimpleS3();
String result = await _simpleS3.uploadFile(
				file, <------------------------------------- Selected File
				bucketName, <------------------------------- Your Bucket Name
				poolID, <----------------------------------- Your POOL ID
				AWSRegions.apSouth1, <---------------------- S3 server region
				subRegion: AWSRegions.apNorthEast1 <-------- Sub region
				);

Debug mode

// for security reasons plugin uses less logs, to enable full logs -

SimpleS3 _simpleS3 = SimpleS3();
String result = await _simpleS3.uploadFile(
				file, <--------------- Selected File
				bucketName, <--------- Your Bucket Name
				poolID, <------------- Your POOL ID
				AWSRegions.apSouth1 <- S3 server region
				debugLog: true, <----- Enable full logs
				);

Android Proguard settings for release mode


// add these lines in your app/build.gradle

		minifyEnabled true  
		useProguard true  
		proguardFiles getDefaultProguardFile('proguard-android.txt'),  
		        'proguard-aws-2.1.5.pro'

//EXAMPLE
		buildTypes {  
		  release {  
		  signingConfig signingConfigs.release  
		  minifyEnabled true  
		  useProguard true  
		  proguardFiles getDefaultProguardFile('proguard-android.txt'),  
		                'proguard-aws-2.1.5.pro'  
		  }  
		}

Now copy contents of this file proguard-aws-2.1.5.pro Create a new file with name "proguard-aws-2.1.5.pro" at the same location as app/build.gradle and paste the copied contents into this file.

Your release mode APK should work now.

所属分类

依赖

依赖清单 1 项

源码仓库

使用此插件的项目

暂无相关数据。