패키지, 저장소 및 앱 카테고리 검색

패키지 상세v1.0.2

tus_client

tus 프로토콜을 사용하여 재시도 가능한 업로드를 허용하는 Dart용 tus 클라이언트입니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
145
좋아요
25
Pub 점수
140

패키지 설치

flutter pub add tus_client

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

tus_client 패키지는 다양한 플랫폼에서 재시도 가능한 파일 업로드를 가능하게 하는 Dart 기반의 tus 프로토콜 구현입니다. 파일을 조각으로 나누고 중단된 전송을 복원함으로써 사용자가 대용량 파일을 신뢰할 수 있게 업로드할 수 있도록 합니다. 이 클라이언트는 Android, iOS, 웹, 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 개

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.