tus js client
v4.2.3
TUSは、再開可能なファイルアップロードのHTTPに基づくプロトコルです。再開可能とは、アップロードをいつでも中断することができ、以前のデータを再度再現せずに再開できることを意味します。ユーザーが一時停止したい場合、またはネットワークの問題やサーバーの停止の場合に偶然に、または偶然に中断が起こる可能性があります。
TUS-JS-Clientは、TUS Resumableアップロードプロトコルの純粋なJavaScriptクライアントであり、ブラウザ、 node.js 、 React NativeおよびApache Cordovaアプリケーション内で使用できます。
プロトコルバージョン: 1.0.0
このブランチには、tus-js-client v4が含まれています。以前の主要なリリースを探している場合、その後、壊れた変更が導入された場合は、v3.1.3タグをご覧ください。
input . addEventListener ( 'change' , function ( e ) {
// Get the selected file from the input element
var file = e . target . files [ 0 ]
// Create a new tus upload
var upload = new tus . Upload ( file , {
endpoint : 'http://localhost:1080/files/' ,
retryDelays : [ 0 , 3000 , 5000 , 10000 , 20000 ] ,
metadata : {
filename : file . name ,
filetype : file . type ,
} ,
onError : function ( error ) {
console . log ( 'Failed because: ' + error )
} ,
onProgress : function ( bytesUploaded , bytesTotal ) {
var percentage = ( ( bytesUploaded / bytesTotal ) * 100 ) . toFixed ( 2 )
console . log ( bytesUploaded , bytesTotal , percentage + '%' )
} ,
onSuccess : function ( ) {
console . log ( 'Download %s from %s' , upload . file . name , upload . url )
} ,
} )
// Check if there are any previous uploads to continue.
upload . findPreviousUploads ( ) . then ( function ( previousUploads ) {
// Found previous uploads so we select the first one.
if ( previousUploads . length ) {
upload . resumeFromPreviousUpload ( previousUploads [ 0 ] )
}
// Start the upload
upload . start ( )
} )
} ) このプロジェクトは、MITライセンスに基づいてライセンスされています。 LICENSEを参照してください。