tus 0.0.2 copy "tus: ^0.0.2" to clipboard
tus: ^0.0.2 copied to clipboard

outdated

A Flutter plugin to upload files using the tus resumable upload protocol. Uses the official TUSKit on iOS and tus-android-client on Android as the underlying clients.

tus-flutter-client #

Protocol

A Flutter plugin to upload files using the tus resumable upload protocol:

Features #

  • Supports multiple upload endpoints.
  • Callbacks for the following events: Progress, Completed and Error.

Pull Requests and Issues #

Pull requests are always welcome!

Installation #

Add the following to your pubspec.yml

dependencies:
  #...
  tus: 0.0.1

Getting Started #

import 'package:tus/tus.dart';

// Create tus client
var tusD = Tus(endpointUrl);

// Setup tus headers
tusD.headers = <String, String>{
  "Authorization": authorizationHeader,
};

// Initialize the tus client
var response = await tusD.initializeWithEndpoint();
response.forEach((dynamic key, dynamic value) {
  print("[$key] $value");
});

// Callbacks for tus events
tusD.onError = (String error, Tus tus) {
  print(error);
  setState(() {
    progressBar = 0.0;
    inProgress = true;
    resultText = error;
  });
};

tusD.onProgress =
    (int bytesWritten, int bytesTotal, double progress, Tus tus) {
  setState(() {
    progressBar = (bytesWritten / bytesTotal);
  });
};

tusD.onComplete = (String result, Tus tus) {
  print("File can be found: $result");
  setState(() {
    inProgress = true;
    progressBar = 1.0;
    resultText = result;
  });
};

// Trigger file upload.
//
await tusD.createUploadFromFile(
    path, // local path on device i.e. /storage/.../image.jpg
    metadata: <String, String>{ // additional metadata 
      "test": "message",
    },
);

// Get the result from your onComplete callback

Future Work #

  • ❌ Write tests and code coverage
  • ❌ tus client for the web

License #

MIT

1
likes
0
pub points
22%
popularity

Publisher

unverified uploader

A Flutter plugin to upload files using the tus resumable upload protocol. Uses the official TUSKit on iOS and tus-android-client on Android as the underlying clients.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on tus