Flutter Uploader는 앱이 백그라운드 또는 종료된 상태에서도 원활한 파일 업로드를 가능하게 하는 Flutter용 백그라운드 업로드 플러그인입니다. 여러 파일 형식을 지원하며 실시간 진행률 추적, 재시도 메커니즘, 일시정지/재개 기능을 제공합니다. 신뢰성과 효율성을 고려하여 설계되었으며 클라우드 스토리지 서비스와 원활하게 통합됩니다. 사용자 경험에 방해 없이 강력한 파일 전송 기능이 필요한 애플리케이션에 적합합니다.
사용 사례
백그라운드 파일 업로드
대용량 파일 전송
오프라인 업로드 재개
실시간 진행 상황 모니터링
앱 라이프사이클 강성
클라우드 스토리지 통합
주요 기능
백그라운드 업로드 기능
진행 추적
업로드 일시정지 및 재개
실패 시 자동 재시도
크로스 플랫폼 지원
간단한 API 통합
적합한 대상
신뢰할 수 있는 파일 업로드가 필요한 앱
미디어 공유 플랫폼
백업 및 동기화 기능
기업용 데이터 전송 앱
업로드 안정성을 우선시하는 개발자
고려 사항
백그라운드 실행을 위해 적절한 권한이 필요합니다
플랫폼별 구성이 필요할 수 있습니다
업로드 작업에 한정됨(다운로드 없음)
네트워크 사용 가능 여부에 따라 다릅니다
실시간 스트리밍에 적합하지 않습니다
생산 환경에서 오류 처리와 함께 사용하는 것이 가장 좋습니다
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
Flutter Uploader
A plugin for creating and managing upload tasks. Supports iOS and Android.
Configure maximum number of connection per host: the plugin allows 3 simultaneous http connection per host running at a moment by default. You can change this number by adding following codes to your Info.plist file.
<!-- changes this number to configure the maximum number of concurrent tasks --><key>FUMaximumConnectionsPerHost</key><integer>3</integer>
Configure maximum number of concurrent upload operation: the plugin allows 3 simultaneous upload operation running at a moment by default. You can change this number by adding following codes to your Info.plist file.
<!-- changes this number to configure the maximum number of concurrent tasks --><key>FUMaximumUploadOperation</key><integer>3</integer>
Configure request timeout: controls how long (in seconds) a task should wait for additional data to arrive before giving up Info.plist file.
<!-- changes this number to configure the request timeout --><key>FUTimeoutInSeconds</key><integer>3600</integer>
Android integration
Optional configuration:
Configure maximum number of concurrent tasks: the plugin depends on WorkManager library and WorkManager depends on the number of available processor to configure the maximum number of tasks running at a moment. You can setup a fixed number for this configuration by adding following codes to your AndroidManifest.xml:
<providerandroid:name="androidx.work.impl.WorkManagerInitializer"android:authorities="${applicationId}.workmanager-init"android:enabled="false"android:exported="false" /><providerandroid:name="com.bluechilli.flutteruploader.FlutterUploaderInitializer"android:authorities="${applicationId}.flutter-upload-init"android:exported="false"><!-- changes this number to configure the maximum number of concurrent tasks --><meta-dataandroid:name="com.bluechilli.flutterupload.MAX_CONCURRENT_TASKS"android:value="3" /><!-- changes this number to configure connection timeout for the upload http request --><meta-dataandroid:name="com.bluechilli.flutteruploader.UPLOAD_CONNECTION_TIMEOUT_IN_SECONDS"android:value="3600" /></provider>
voidbackgroundHandler() {
// Needed so that plugin communication works.WidgetsFlutterBinding.ensureInitialized();
// This uploader instance works within the isolate only.FlutterUploader uploader = FlutterUploader();
// You have now access to:
uploader.progress.listen((progress) {
// upload progress
});
uploader.result.listen((result) {
// upload results
});
}
The backgroundHandler function needs to be either a static function or a top level function to be accessible as a Flutter entry point.
Once you have a function defined, configure it in your main FlutterUploader object like so:
final taskId = awaitFlutterUploader().enqueue(
MultipartFormDataUpload(
url: "your upload link", //required: url to upload to
files: [FileItem(path: '/path/to/file', fieldname:"file")], // required: list of files that you want to upload
method: UploadMethod.POST, // HTTP method (POST or PUT or PATCH)
headers: {"apikey": "api_123456", "userkey": "userkey_123456"},
data: {"name": "john"}, // any data you want to send in upload request
tag: 'my tag', // custom tag which is returned in result/progress
),
);
binary uploads:
final taskId = awaitFlutterUploader().enqueue(
RawUpload(
url: "your upload link", // required: url to upload to
path: '/path/to/file', // required: list of files that you want to upload
method: UploadMethod.POST, // HTTP method (POST or PUT or PATCH)
headers: {"apikey": "api_123456", "userkey": "userkey_123456"},
tag: 'my tag', // custom tag which is returned in result/progress
),
);
The plugin will return a taskId which is unique for each upload. Hold onto it if you in order to cancel specific uploads.
listen for upload progress
final subscription = FlutterUploader().progress.listen((progress) {
//... code to handle progress
});
listen for upload result
final subscription = FlutterUploader().result.listen((result) {
//... code to handle result
}, onError: (ex, stacktrace) {
// ... code to handle error
});
when tasks are cancelled, it will send on onError handler as exception with status = cancelled
Upload results are persisted by the plugin and will be submitted on each .listen.
It is advised to keep a list of processed uploads in App side and call clearUploads on the FlutterUploader plugin once they can be removed.