Commit 3760489f by Johannes Zellner

Superagent is a bit bogus

1 parent 5c17272a
Showing with 6 additions and 1 deletions
......@@ -146,11 +146,16 @@ function uploadFiles(files) {
var formData = new FormData();
formData.append('file', file);
var finishedUploadSize = app.uploadStatus.done;
superagent.post('/api/files' + path)
.query({ access_token: localStorage.accessToken })
.send(formData)
.on('progress', function (event) {
app.uploadStatus.done += event.loaded;
// only handle upload events
if (!(event.target instanceof XMLHttpRequestUpload)) return;
app.uploadStatus.done = finishedUploadSize + event.loaded;
app.uploadStatus.percentDone = Math.round(app.uploadStatus.done / app.uploadStatus.size * 100);
}).end(function (error, result) {
if (result && result.statusCode === 401) return logout();
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!