mirror of
https://github.com/logto-io/logto.git
synced 2025-01-20 21:32:31 -05:00
fix(core): fix upload file guard (#5810)
fix: remove the plus sign in front of the phone number (#5801) Co-authored-by: Kamto <kam_to@outlook.com>
This commit is contained in:
parent
224723413a
commit
3486b12e86
2 changed files with 14 additions and 2 deletions
10
.changeset/smart-melons-shop.md
Normal file
10
.changeset/smart-melons-shop.md
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
---
|
||||||
|
"@logto/phrases": patch
|
||||||
|
"@logto/core": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix file upload API.
|
||||||
|
|
||||||
|
The `koa-body` has been upgraded to the latest version, which caused the file upload API to break. This change fixes the issue.
|
||||||
|
|
||||||
|
The `ctx.request.files.file` in the new version is an array, so the code has been updated to pick the first one.
|
|
@ -52,13 +52,15 @@ export default function userAssetsRoutes<T extends ManagementApiRouter>(
|
||||||
'/user-assets',
|
'/user-assets',
|
||||||
koaGuard({
|
koaGuard({
|
||||||
files: object({
|
files: object({
|
||||||
file: uploadFileGuard,
|
file: uploadFileGuard.array().min(1),
|
||||||
}),
|
}),
|
||||||
response: userAssetsGuard,
|
response: userAssetsGuard,
|
||||||
}),
|
}),
|
||||||
async (ctx, next) => {
|
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(file.size <= maxUploadFileSize, 'guard.file_size_exceeded');
|
||||||
assertThat(
|
assertThat(
|
||||||
allowUploadMimeTypes.map(String).includes(file.mimetype),
|
allowUploadMimeTypes.map(String).includes(file.mimetype),
|
||||||
|
|
Loading…
Add table
Reference in a new issue