uploadthing 1.0.0 copy "uploadthing: ^1.0.0" to clipboard
uploadthing: ^1.0.0 copied to clipboard

An unofficial Dart/Flutter SDK for the UploadThing API.

UploadThing Dart SDK #

An unofficial Dart/Flutter SDK for the UploadThing API, providing easy file upload capabilities. This package allows you to integrate file upload features seamlessly into your Dart or Flutter application using the UploadThing service.

Features #

  • Simple and easy-to-use
  • Upload single or multiple files with ease
  • Track upload progress and manage file data
  • Supports various file types

Installation #

Add the following dependency to your pubspec.yaml file:

dependencies:
  uploadthing: ^1.0.0

Then, run:

flutter pub get

Usage #

Import the package #

import 'package:uploadthing/uploadthing.dart';
import 'dart:io';

Initialize and Upload Files #

void main() async {
  final uploadThing = UploadThing('YOUR_API_KEY');

  List<File> files = [
    File('path/to/file1.jpg'),
    File('path/to/file2.png'),
  ];

  try {
    await uploadThing.uploadFile(files);
    print('Uploaded files: ${uploadThing.uploadedFilesData}');
  } catch (e) {
    print('Error: $e');
  }
}

Handling Upload Progress #

You can track the progress of uploaded files using uploadedFiles and totalFiles:

print('Uploaded ${uploadThing.uploadedFiles} of ${uploadThing.totalFiles} files');

Uploaded Files Data #

Once the files are uploaded, you can access the uploaded file data:

for (var fileData in uploadThing.uploadedFilesData) {
  print('File URL: ${fileData['url']}');
}

API Reference #

UploadThing(String apiKey) #

Creates an instance of the UploadThing class with the provided API key.

Future<void> uploadFile(List<File> files) #

Uploads a list of files to the UploadThing API.

  • Parameters:

    • files: A list of File objects to be uploaded.
  • Exceptions:

    • Throws an exception if the upload fails.

Configuration #

Ensure you replace 'YOUR_API_KEY' with your UploadThing API key. You can obtain the API key from your UploadThing dashboard.

Error Handling #

Make sure to handle exceptions properly when calling uploadFile to catch any errors during the upload process.

try {
  await uploadThing.uploadFile(files);
} catch (e) {
  print('Error occurred: $e');
}

Documentation #

For more details about UploadThing, refer to the UploadThing API Documentation.

Contributions #

Contributions are welcome! Please feel free to submit a pull request or report issues.

4
likes
0
points
34
downloads

Publisher

verified publisheraqeelshamz.com

Weekly Downloads

An unofficial Dart/Flutter SDK for the UploadThing API.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, http, http_parser, mime

More

Packages that depend on uploadthing