Skip to content

Commit a6bc6b5

Browse files
committed
Merge branch 'master' of https://github.com/coosto/vue-upload-component into chunk
2 parents 8e557d0 + 4d1a879 commit a6bc6b5

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

src/FileUpload.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ import ChunkUploadDefaultHandler from './chunk/ChunkUploadHandler'
3737
import InputFile from './InputFile.vue'
3838
3939
const CHUNK_DEFAULT_OPTIONS = {
40-
headers: {
41-
'Content-Type': 'application/json'
42-
},
40+
headers: {},
4341
action: '',
4442
minSize: 1048576,
4543
maxActive: 3,

src/chunk/ChunkUploadHandler.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,13 @@ export default class ChunkUploadHandler {
168168
*/
169169
pause () {
170170
this.file.active = false
171+
this.stopChunks()
172+
}
173+
174+
/**
175+
* Stops all the current chunks
176+
*/
177+
stopChunks () {
171178
this.chunksUploading.forEach(chunk => {
172179
chunk.xhr.abort()
173180
chunk.active = false
@@ -208,7 +215,7 @@ export default class ChunkUploadHandler {
208215
start () {
209216
request({
210217
method: 'POST',
211-
headers: Object.assign(this.headers, {
218+
headers: Object.assign({}, this.headers, {
212219
'Content-Type': 'application/json'
213220
}),
214221
url: this.action,
@@ -275,9 +282,7 @@ export default class ChunkUploadHandler {
275282
this.updateFileProgress()
276283
chunk.xhr = createRequest({
277284
method: 'POST',
278-
headers: Object.assign(this.headers, {
279-
'Content-Type': 'multipart/form-data'
280-
}),
285+
headers: this.headers,
281286
url: this.action
282287
})
283288

@@ -298,7 +303,7 @@ export default class ChunkUploadHandler {
298303
chunk.uploaded = true
299304
} else {
300305
if (chunk.retries-- <= 0) {
301-
this.pause()
306+
this.stopChunks()
302307
return this.reject('upload')
303308
}
304309
}
@@ -307,7 +312,7 @@ export default class ChunkUploadHandler {
307312
}).catch(() => {
308313
chunk.active = false
309314
if (chunk.retries-- <= 0) {
310-
this.pause()
315+
this.stopChunks()
311316
return this.reject('upload')
312317
}
313318

@@ -324,7 +329,7 @@ export default class ChunkUploadHandler {
324329

325330
request({
326331
method: 'POST',
327-
headers: Object.assign(this.headers, {
332+
headers: Object.assign({}, this.headers, {
328333
'Content-Type': 'application/json'
329334
}),
330335
url: this.action,

0 commit comments

Comments
 (0)