0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-02-17 22:04:19 -05:00

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

This commit is contained in:
Charles Zhao 2024-06-03 17:45:42 +08:00 committed by GitHub
parent 391717637c
commit 14515f2c44
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -57,13 +57,15 @@ export default function userAssetsRoutes<T extends AuthedMeRouter>(...[router]:
'/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;
const file = bodyFiles[0];
assertThat(file, 'guard.invalid_input');
assertThat(file.size <= maxUploadFileSize, 'guard.file_size_exceeded');
assertThat(
allowUploadMimeTypes.map(String).includes(file.mimetype),