パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v1.0.2

tus_client

tusプロトコルを使用して再開可能なアップロードを可能にするDart用のtusクライアントです。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
145
いいね数
25
Pub ポイント
140

パッケージをインストール

flutter pub add tus_client

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

tus_client パッケージは、tus プロトコルの Dart 実装であり、さまざまなプラットフォームで再開可能なファイルアップロードを可能にします。大容量のファイルをチャンクに分割し、中断された転送を再開することで、ユーザーが信頼性の高い方法でファイルをアップロードできるようにします。このクライアントは、Android、iOS、Web、macOS、Windows、Linux を含むすべての主要プラットフォームをサポートしています。堅牢性と効率性を重視して設計されており、ネットワークの切断を適切に処理し、アップロード中のデータ整合性を保証します。セキュアでスケーラブルなファイル転送機能が必要なアプリケーションに最適です。

用途

  • 大容量ファイルのアップロード
  • オフライン優先のファイル転送
  • クラウドストレージ統合
  • アップロード中の進行状況の追跡
  • 中断されたアップロードを再開する

主な機能

  • 再開可能なアップロード
  • クロスプラットフォーム対応
  • チャンク化ファイル転送
  • アップロード進捗のモニタリング
  • エラー時の自動再試行

適している対象

  • ファイル重視のアプリケーション
  • アップロードが必要なモバイルおよびウェブアプリ
  • 信頼性の高いデータ転送を必要とするアプリケーション
  • tusプロトコルを使用する開発者
  • tus クライアントと統合されたバックエンドサービス

注意事項

  • tus互換サーバーが必要です
  • ファイルアップロードの使用事例に限定
  • カスタムヘッダー用に追加の構成が必要になる場合があります
  • ストリーミングまたはリアルタイムデータには適していません
  • 最適なパフォーマンスのためには安定したインターネット接続が必要です

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

A tus client

Pub Version Build Status codecov


A tus client in pure dart. Resumable uploads using tus protocol

tus is a protocol based on HTTP for resumable file uploads. Resumable means that an upload can be interrupted at any moment and can be resumed without re-uploading the previous data again. An interruption may happen willingly, if the user wants to pause, or by accident in case of a network issue or server outage.

Usage

import 'package:cross_file/cross_file.dart' show XFile;

// File to be uploaded
final file = XFile("/path/to/my/pic.jpg");

// Create a client
final client = TusClient(
    Uri.parse("https://master.tus.io/files/"),
    file,
    store: TusMemoryStore(),
);

// Starts the upload
await client.upload(
    onComplete: () {
        print("Complete!");

        // Prints the uploaded file URL
        print(client.uploadUrl.toString());
    },
    onProgress: (progress) {
        print("Progress: $progress");
    },
);
Using Persistent URL Store

This is only supported on Flutter Android, iOS, desktop and web. You need to add to your pubspec.yaml:

dependencies:
  tus_client: ^1.0.2
  tus_client_file_store: ^0.0.3
import 'package:path_provider/path_provider.dart';
import 'package:tus_client_file_store/tus_client_file_store.dart' show TusFileStore;
import 'package:path/path.dart' as p;

// Directory the current uploads will be saved in
final tempDir = (await getTemporaryDirectory()).path;
final tempDirectory = Directory(p.join(tempDir, "tus-uploads"));

// Create a client
final client = TusClient(
    Uri.parse("https://example.com/tus"),
    file,
    store: TusFileStore(tempDirectory),
);

// Start upload
await client.upload();
Adding Extra Headers
final client = TusClient(
    Uri.parse("https://master.tus.io/files/"),
    file,
    headers: {"Authorization": "..."},
);
Adding extra data
final client = TusClient(
    Uri.parse("https://master.tus.io/files/"),
    file,
    metadata: {"for-gallery": "..."},
);
Changing chunk size

The file is uploaded in chunks. Default size is 512KB. This should be set considering speed of upload vs device memory constraints

final client = TusClient(
    Uri.parse("https://master.tus.io/files/"),
    file,
    maxChunkSize: 10 * 1024 * 1024,  // chunk is 10MB
);
Pausing upload

Pausing upload can be done after current uploading in chunk is completed.

final client = TusClient(
    Uri.parse("https://master.tus.io/files/"),
    file
);

// Pause after 5 seconds
Future.delayed(Duration(seconds: 5)).then((_) =>client.pause());

// Starts the upload
await client.upload(
    onComplete: () {
        print("Complete!");
    },
    onProgress: (progress) {
        print("Progress: $progress");
    },
);

Example

For an example of usage in a Flutter app (using file picker) see: /example

Maintainers

カテゴリー

依存関係

依存関係一覧 3 件

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。