Skip to content

PhilipHayes/TUSKit

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TUSKit

Protocol Version License Platform

An iOS client written in Objective-C for tus resumable upload protocol.

Note: TUSKit 1.3.1

TUSKit 1.3.1 is not yet out on Cocoapods, but can be installed by downloading the repo and including the /Pod/Classes folder into your project.

This version has improved upload storage and background uploads. Sparse documentation can be found in the example. After the pod is released full documentation will follow.

Pull Requests

Pull requests are always welcome! However, please submit a PR to the development branch in order to keep the master branch match up with the TUSKit pod at all times.

Installation

TUSKit is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "TUSKit"

Example Project

To run the example project, clone the repo, and run pod install from the Example directory first.

The Protocol

You'll need a tus.io friendly server before using TUSKit or any other tus client. You can find a list of tus implementations here.

Usage


TUSAssetData

Each file you upload must be in the form of a TUSAssetData object. Create an TUSAssetData object by initializing with an ALAsset object.

TUSAssetData *uploadData = [[TUSAssetData alloc] initWithAsset:asset];

TUSResumableUpload

An upload can be created by initializing a TUSResumableUpload object. If your server requires specific headers for communication such as authentication, you may pass these headers on initialization.

TUSResumableUpload *upload = [[TUSResumableUpload alloc] initWithURL:UPLOAD_ENDPOINT data:uploadData fingerprint:fingerprint uploadHeaders:headers fileName:@"video.mp4"];

URL - The URL to your tus.io server.

data - The TUSAssetData object you are uploading.

fingerprint - The absoulute path to the asset.

uploadHeaders - An NSDictionary of your custom headers for the upload.

filename - The filename...

Upload Start

To start the upload process, run the start method on your TUSResumableUpload object.

[upload start];

progressBlock

A block to track progess on your upload. Here you can update your progress bar, print to the log, etc.

    upload.progressBlock = ^(NSInteger bytesWritten, NSInteger bytesTotal){
       NSLog(@"progress: %d / %d", bytesWritten, bytesTotal);
    };

resultBlock

A block fired after a successful upload, returning the URL to your file on the server. Handle your success here!

    upload.resultBlock = ^(NSURL* fileURL){
       NSLog(@"url: %@", fileURL);
    };

failureBlock

A block fired after a failed upload, returning the error. Handle your failure here!

    upload.failureBlock = ^(NSError* error){
       NSLog(@"error: %@", error);
    };

Todo


  • Background Uploads

About tus.io:


Users want to share more and more photos and videos. But mobile networks are fragile. Platform APIs are a mess. Every project builds its own file uploader. A thousand one week projects that barely work, when all we need is one real project, done right.

We are going to do this right. We will solve reliable file uploads for once and for all. A new open protocol for resumable uploads built on HTTP. Simple, cheap, reusable stacks for clients and servers. Any language, any platform, any network.

TUSKit is a ready to use tus client for iOS.

License


TUSKit is available under the MIT license. See the LICENSE file for more info.

About

The tus client for iOS.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Objective-C 98.6%
  • Ruby 1.4%