Skip to content

Commit

Permalink
✅ Fix fileupload stub
Browse files Browse the repository at this point in the history
  • Loading branch information
williamchong committed Nov 23, 2022
1 parent 606a442 commit 4535e73
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions test/stub/util/fileupload.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand All @@ -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) {
Expand Down

0 comments on commit 4535e73

Please sign in to comment.