fix upload
This commit is contained in:
parent
c25861a4e9
commit
5c60f4ac09
@ -126,7 +126,6 @@ export async function post(url, content = '', overwrite = false, onupload) {
|
||||
return;
|
||||
}
|
||||
|
||||
debugger;
|
||||
let fileSize = content.size;
|
||||
let mb = 1024 * 1024;
|
||||
let fileSizeMB = fileSize / mb;
|
||||
@ -147,11 +146,12 @@ export async function post(url, content = '', overwrite = false, onupload) {
|
||||
endInex = fileSize;
|
||||
}
|
||||
fileContent = blobSlice.call(allContent, startIndex, endInex);
|
||||
|
||||
|
||||
debugger;
|
||||
let params = `&fileID=${fileID}&chunckIndex=${index + 1}&totalChunck=${totalChunks}`
|
||||
await partialUpload(url, params, fileContent).catch(err => {
|
||||
debugger;
|
||||
await partialUpload(url, params, fileContent).then(() => {
|
||||
tryCount = 0;
|
||||
}).catch(err => {
|
||||
if (tryCount <= 2) {//one file try three times
|
||||
index--;
|
||||
tryCount++;
|
||||
@ -159,7 +159,6 @@ export async function post(url, content = '', overwrite = false, onupload) {
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
tryCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -6,10 +6,12 @@ const getters = {
|
||||
isPreview: state => state.previewMode,
|
||||
selectedCount: state => state.selected.length,
|
||||
progress : state => {
|
||||
/* eslint-disable no-debugger */
|
||||
|
||||
if (state.upload.progress.length == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
debugger;
|
||||
let sum = state.upload.progress.reduce((acc, val) => acc + val)
|
||||
return Math.ceil(sum / state.upload.size * 100);
|
||||
}
|
||||
|
||||
@ -12,9 +12,10 @@ const state = {
|
||||
queue: [],
|
||||
uploads: {}
|
||||
}
|
||||
|
||||
/* eslint-disable no-debugger */
|
||||
const mutations = {
|
||||
setProgress(state, { id, loaded }) {
|
||||
debugger;
|
||||
Vue.set(state.progress, id, loaded)
|
||||
},
|
||||
reset: (state) => {
|
||||
|
||||
@ -139,7 +139,7 @@ var resourcePostPutHandler = withUser(func(w http.ResponseWriter, r *http.Reques
|
||||
filePath = dir + spieceFileName
|
||||
if totalChunck != chunckIndex {
|
||||
_, err := d.user.Fs.Stat(filePath)
|
||||
if err != nil {
|
||||
if err == nil {
|
||||
//the piece has exist
|
||||
isPieceHasUpload = true
|
||||
}
|
||||
@ -152,7 +152,7 @@ var resourcePostPutHandler = withUser(func(w http.ResponseWriter, r *http.Reques
|
||||
return err
|
||||
}
|
||||
|
||||
file, err := d.user.Fs.OpenFile(filePath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0775)
|
||||
file, err = d.user.Fs.OpenFile(filePath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0775)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -172,10 +172,11 @@ var resourcePostPutHandler = withUser(func(w http.ResponseWriter, r *http.Reques
|
||||
if chunckIndex == totalChunck && totalChunckInt > 1 {
|
||||
//merge all spiece files
|
||||
itemPath := ""
|
||||
var err error
|
||||
//create original file
|
||||
file, _err := d.user.Fs.OpenFile(r.URL.Path, os.O_CREATE|os.O_APPEND|os.O_RDWR, 0777)
|
||||
if _err != nil {
|
||||
return _err
|
||||
file, err = d.user.Fs.OpenFile(r.URL.Path, os.O_CREATE|os.O_APPEND|os.O_RDWR, 0777)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user