tus js client
v4.2.3
TUS는 재개 가능한 파일 업로드를 위한 HTTP를 기반으로 한 프로토콜입니다. 재개 가능하면 업로드는 언제라도 중단 될 수 있으며 이전 데이터를 다시 업로드하지 않고 재개 될 수 있습니다. 사용자가 일시 중지하려는 경우 또는 네트워크 문제 또는 서버 중단의 경우 우연히 발생하는 경우 기꺼이 중단이 발생할 수 있습니다.
TUS-JS-CLIENT는 TUS 재개 가능한 업로드 프로토콜의 순수한 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 참조하십시오.