All Projects → vinzscam → react-native-tus-client

vinzscam / react-native-tus-client

Licence: MIT license
React Native client for the tus resumable upload protocol.

Programming Languages

java
68154 projects - #9 most used programming language
objective c
16641 projects - #2 most used programming language
javascript
184084 projects - #8 most used programming language
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to react-native-tus-client

Chibisafe
Blazing fast file uploader and awesome bunker written in node! 🚀
Stars: ✭ 657 (+1628.95%)
Mutual labels:  upload, file-upload, uploader
Angular File Uploader
Angular file uploader is an Angular 2/4/5/6/7/8/9/10 + file uploader module with Real-Time Progress Bar, Responsive design, Angular Universal Compatibility, localization and multiple themes which includes Drag and Drop and much more.
Stars: ✭ 92 (+142.11%)
Mutual labels:  upload, file-upload, uploader
Uploadcare Php
PHP API client that handles uploads and further operations with files by wrapping Uploadcare Upload and REST APIs.
Stars: ✭ 77 (+102.63%)
Mutual labels:  upload, file-upload, uploader
google-music-manager-uploader
Google Music Manager Uploader module / Easily upload MP3 (folder) to Google Music
Stars: ✭ 21 (-44.74%)
Mutual labels:  upload, uploader, upload-file
lolisafe
Blazing fast file uploader and awesome bunker written in node! 🚀
Stars: ✭ 181 (+376.32%)
Mutual labels:  upload, file-upload, uploader
RxUploader
Uploader for Android using RxJava
Stars: ✭ 72 (+89.47%)
Mutual labels:  upload, uploader, upload-file
uploadcare client
A flutter library for working with Uploadcare REST API. File uploads, media processing, and adaptive delivery for web and mobile.
Stars: ✭ 14 (-63.16%)
Mutual labels:  file-upload, uploader, upload-file
rustypaste
A minimal file upload/pastebin service.
Stars: ✭ 102 (+168.42%)
Mutual labels:  upload, file-upload, upload-file
Uploadcare Widget
Uploadcare Widget, an ultimate tool for HTML5 file upload supporting multiple file upload, drag&drop, validation by file size/file extension/MIME file type, progress bar for file uploads, image preview.
Stars: ✭ 183 (+381.58%)
Mutual labels:  upload, file-upload, uploader
Tus Java Server
Library to receive tus v1.0.0 file uploads in a Java server environment
Stars: ✭ 64 (+68.42%)
Mutual labels:  upload, file-upload
Django-WebApp
This is a web-app created using Python, Django. By using this user can login, upload files and also can view and download files uploaded by other users.
Stars: ✭ 285 (+650%)
Mutual labels:  file-upload, upload-file
React Images Uploading
The simple images uploader applied Render Props pattern that allows you to fully control UI component and behaviors.
Stars: ✭ 80 (+110.53%)
Mutual labels:  upload, uploader
Laravel Simple Uploader
Simple file uploader for Laravel 5.
Stars: ✭ 59 (+55.26%)
Mutual labels:  upload, uploader
Express Fileupload
Simple express file upload middleware that wraps around busboy
Stars: ✭ 1,069 (+2713.16%)
Mutual labels:  upload, file-upload
Droply Js
Droply JS, a new responsive and cross browser chunk uploader with DragDrop and File Preview capabilities (HTML5/CSS3)
Stars: ✭ 50 (+31.58%)
Mutual labels:  upload, uploader
Go Tus
A pure Go client for the tus resumable upload protocol
Stars: ✭ 105 (+176.32%)
Mutual labels:  upload, uploader
Linx Server
Self-hosted file/code/media sharing website. ~~~~~~~~~~~~~~~~~~~ Demo: https://demo.linx-server.net/
Stars: ✭ 1,044 (+2647.37%)
Mutual labels:  upload, file-upload
Direct Upload
Composer Package to Direct Upload to S3
Stars: ✭ 84 (+121.05%)
Mutual labels:  upload, file-upload
Curldrop
⏫ web app for for easy file uploads via curl
Stars: ✭ 125 (+228.95%)
Mutual labels:  upload, uploader
Cakephp File Storage
Abstract file storage and upload plugin for CakePHP. Write to local disk, FTP, S3, Dropbox and more through a single interface. It's not just yet another uploader but a complete storage solution.
Stars: ✭ 202 (+431.58%)
Mutual labels:  upload, uploader

react-native-tus-client

React Native client for the tus resumable upload protocol tus.io inspired to tus-js-client.

It provides a native tus compliant implementation through the official TUSKit and tus-android-client libraries.

Getting started

$ npm install react-native-tus-client --save

or

$ yarn add react-native-tus-client

Mostly automatic installation

# RN >= 0.60
cd ios && pod install

# RN < 0.60
react-native link react-native-tus-client

Manual installation

iOS

  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_modulesreact-native-tus-client and add RNTusClient.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libRNTusClient.a to your project's Build PhasesLink Binary With Libraries
  4. Run your project (Cmd+R)

Android

  1. Open up android/app/src/main/java/[...]/MainActivity.java
  • Add import com.vinzscam.RNTusClientPackage; to the imports at the top of the file
  • Add new RNTusClientPackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
    include ':react-native-tus-client'
    project(':react-native-tus-client').projectDir = new File(rootProject.projectDir, 	'../node_modules/react-native-tus-client/android')
    
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
      compile project(':react-native-tus-client')
    

Usage

All you need to know to upload a file to a tus server is the local absolute path where the file is stored. If you know it, you can just invoke the library as described in the snippet at the end of this section. If you don't know where your file is stored, some other library like react-native-image-picker might help you.

Upload a file by its absolute path

import { Upload } from 'react-native-tus-client';

const absoluteFilePath = // absolute path to your file;
const upload = new Upload(absoluteFilePath, {
  endpoint: 'https://master.tus.io/files/', // use your tus server endpoint instead
  onError: error => console.log('error', error),
  onSuccess: () => {
    console.log('Upload completed! File url:', upload.url);
  },
  onProgress: (uploaded, total) => console.log(
    `Progress: ${(uploaded/total*100)|0}%`)
});
upload.start();

Upload an image using react-native-image-picker

import ImagePicker from 'react-native-image-picker';
import { Upload } from 'react-native-tus-client';

new Promise((resolve, reject) => {
  ImagePicker.showImagePicker({ }, ({ uri, error, path }) => {
    return uri ? resolve(path || uri) : reject(error || null);
  });
})
.then(file => {
  const upload = new Upload(file, {
    endpoint: 'https://master.tus.io/files/', // use your tus server endpoint instead
    onError: error => console.log('error', error),
    onSuccess: () => {
      console.log('Upload completed. File url:', upload.url);
    },
    onProgress: (uploaded, total) => console.log(
      `Progress: ${(uploaded/total*100)|0}%`)
  });
  upload.start();
})
.catch(e => console.log('error', e));

API

Class Upload

Class representing a tus upload.

Constructor

new Upload(file, settings)

Parameters:
Name Type Description
file string The file absolute path
options object The options argument used to setup your tus upload. See below.

Options:

Property Type Mandatory Description
endpoint string Yes URL used to create the upload
headers object No An object with custom header values used in all requests.
metadata object No An object with string values used as additional meta data which will be passed along to the server when (and only when) creating a new upload. Can be used for filenames, file types etc.
onError function No a function called once an error appears. The arguments will be an Error instance.
onProgress function No a function that will be called each time progress information is available. The arguments will be bytesSent and bytesTotal
onSuccess function No a function called when the upload finished successfully.

Methods

Name Description
start Start or resume the upload using the specified file. If no file property is available the error handler will be called.
abort Abort the currently running upload request and don't continue. You can resume the upload by calling the start method again.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].