From 4535e73c6811592b2c27d9f960426ffd553dc43c Mon Sep 17 00:00:00 2001 From: William Chong Date: Wed, 23 Nov 2022 15:19:45 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20Fix=20fileupload=20stub?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/stub/util/fileupload.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/stub/util/fileupload.js b/test/stub/util/fileupload.js index 1db4bbc8c..fabf55636 100644 --- a/test/stub/util/fileupload.js +++ b/test/stub/util/fileupload.js @@ -22,8 +22,8 @@ export async function handleAvatarUploadAndGetURL(user, file, avatarSHA256) { throw new ValidationError(`unsupported file format! ${(type || {}).ext || JSON.stringify(type)}`); } + const hash256 = sha256(file.buffer); if (avatarSHA256) { - const hash256 = sha256(file.buffer); if (hash256 !== avatarSHA256) throw new ValidationError('avatar sha not match'); } @@ -34,7 +34,7 @@ export async function handleAvatarUploadAndGetURL(user, file, avatarSHA256) { mimetype: file.mimetype, }); const versionHash = md5(file.buffer).substring(0, 7); - return `${avatarUrl}&${versionHash}`; + return { url: `${avatarUrl}&${versionHash}`, hash: hash256 }; } export async function handleAvatarLinkAndGetURL(user, url) {