Skip to content

Commit

Permalink
feat: allow keys in response
Browse files Browse the repository at this point in the history
  • Loading branch information
kukhariev committed Feb 18, 2019
1 parent f175c34 commit 5c640c2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ app.use('/upload/', auth, (req, res, next) => {

const location = `${req.protocol}://${req.hostname}:${PORT}/upload/${query}`;
res.location(location);
res.sendStatus(200);
res.json(200, { location });
});

// ------------------------------ ERROR HANDLER ------------------------------
Expand Down
11 changes: 6 additions & 5 deletions src/uploadx/src/uploader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,12 @@ function getRange(xhr: XMLHttpRequest) {
const match = getKeyFromResponse(xhr, 'Range').match(/(-1|\d+)$/g);
return 1 + +(match && match[0]);
}
};
this.status = 'error';
XHRFactory.release(xhr);
this.options.nextFile();
}

function getKeyFromResponse(xhr: XMLHttpRequest, key: string) {
const fromHeader = xhr.getResponseHeader(key);
if (fromHeader) {
return fromHeader;
}
};
const onDataSendSuccess = () => {
if (xhr.status === 200 || xhr.status === 201) {
Expand Down

0 comments on commit 5c640c2

Please sign in to comment.