|
|
|
@ -168,6 +168,13 @@ export default class ChunkUploadHandler {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
pause () {
|
|
|
|
pause () {
|
|
|
|
this.file.active = false
|
|
|
|
this.file.active = false
|
|
|
|
|
|
|
|
this.stopChunks()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Stops all the current chunks
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
stopChunks () {
|
|
|
|
this.chunksUploading.forEach(chunk => {
|
|
|
|
this.chunksUploading.forEach(chunk => {
|
|
|
|
chunk.xhr.abort()
|
|
|
|
chunk.xhr.abort()
|
|
|
|
chunk.active = false
|
|
|
|
chunk.active = false
|
|
|
|
@ -208,7 +215,7 @@ export default class ChunkUploadHandler {
|
|
|
|
start () {
|
|
|
|
start () {
|
|
|
|
request({
|
|
|
|
request({
|
|
|
|
method: 'POST',
|
|
|
|
method: 'POST',
|
|
|
|
headers: Object.assign(this.headers, {
|
|
|
|
headers: Object.assign({}, this.headers, {
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
url: this.action,
|
|
|
|
url: this.action,
|
|
|
|
@ -275,9 +282,7 @@ export default class ChunkUploadHandler {
|
|
|
|
this.updateFileProgress()
|
|
|
|
this.updateFileProgress()
|
|
|
|
chunk.xhr = createRequest({
|
|
|
|
chunk.xhr = createRequest({
|
|
|
|
method: 'POST',
|
|
|
|
method: 'POST',
|
|
|
|
headers: Object.assign(this.headers, {
|
|
|
|
headers: this.headers,
|
|
|
|
'Content-Type': 'multipart/form-data'
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
url: this.action
|
|
|
|
url: this.action
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
@ -298,7 +303,7 @@ export default class ChunkUploadHandler {
|
|
|
|
chunk.uploaded = true
|
|
|
|
chunk.uploaded = true
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (chunk.retries-- <= 0) {
|
|
|
|
if (chunk.retries-- <= 0) {
|
|
|
|
this.pause()
|
|
|
|
this.stopChunks()
|
|
|
|
return this.reject('upload')
|
|
|
|
return this.reject('upload')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -307,7 +312,7 @@ export default class ChunkUploadHandler {
|
|
|
|
}).catch(() => {
|
|
|
|
}).catch(() => {
|
|
|
|
chunk.active = false
|
|
|
|
chunk.active = false
|
|
|
|
if (chunk.retries-- <= 0) {
|
|
|
|
if (chunk.retries-- <= 0) {
|
|
|
|
this.pause()
|
|
|
|
this.stopChunks()
|
|
|
|
return this.reject('upload')
|
|
|
|
return this.reject('upload')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -324,7 +329,7 @@ export default class ChunkUploadHandler {
|
|
|
|
|
|
|
|
|
|
|
|
request({
|
|
|
|
request({
|
|
|
|
method: 'POST',
|
|
|
|
method: 'POST',
|
|
|
|
headers: Object.assign(this.headers, {
|
|
|
|
headers: Object.assign({}, this.headers, {
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
url: this.action,
|
|
|
|
url: this.action,
|
|
|
|
|