apps: make uploadFile async
This commit is contained in:
@@ -783,7 +783,7 @@ async function listBackups(req, res, next) {
|
||||
next(new HttpSuccess(200, { backups: result }));
|
||||
}
|
||||
|
||||
function uploadFile(req, res, next) {
|
||||
async function uploadFile(req, res, next) {
|
||||
assert.strictEqual(typeof req.app, 'object');
|
||||
|
||||
if (typeof req.query.file !== 'string' || !req.query.file) return next(new HttpError(400, 'file query argument must be provided'));
|
||||
@@ -791,11 +791,11 @@ function uploadFile(req, res, next) {
|
||||
|
||||
req.clearTimeout();
|
||||
|
||||
apps.uploadFile(req.app, req.files.file.path, req.query.file, function (error) {
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
const [error] = await safe(apps.uploadFile(req.app, req.files.file.path, req.query.file));
|
||||
safe.fs.unlinkSync(req.files.file.path); // remove file in /tmp
|
||||
|
||||
next(new HttpSuccess(202, {}));
|
||||
});
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
next(new HttpSuccess(202, {}));
|
||||
}
|
||||
|
||||
function downloadFile(req, res, next) {
|
||||
|
||||
Reference in New Issue
Block a user