Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): profile avatar upload should not return 400 error #5974

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/core/src/routes-me/user-assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,15 @@
'/user-assets',
koaGuard({
files: object({
file: uploadFileGuard,
file: uploadFileGuard.array().min(1),
}),
response: userAssetsGuard,
}),
async (ctx, next) => {
const { file } = ctx.guard.files;
const { file: bodyFiles } = ctx.guard.files;

Check warning on line 65 in packages/core/src/routes-me/user-assets.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/routes-me/user-assets.ts#L65

Added line #L65 was not covered by tests

const file = bodyFiles[0];
assertThat(file, 'guard.invalid_input');

Check warning on line 68 in packages/core/src/routes-me/user-assets.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/routes-me/user-assets.ts#L67-L68

Added lines #L67 - L68 were not covered by tests
charIeszhao marked this conversation as resolved.
Show resolved Hide resolved
assertThat(file.size <= maxUploadFileSize, 'guard.file_size_exceeded');
assertThat(
allowUploadMimeTypes.map(String).includes(file.mimetype),
Expand Down
Loading