Strapi 5 使用 koa-body v6
🌐 Strapi 5 uses koa-body v6
Strapi 5 使用 `koa-body` v6,这将 formidable 更新到 v2。这意味着上传的文件具有新的属性。
🌐 Strapi 5 uses `koa-body` v6, which updates formidable to v2. This means uploaded files have new properties.
此页面是重大更改数据库的一部分,提供关于重大更改的信息以及从 Strapi v4 迁移到 Strapi 5 的附加说明。
🌐 This page is part of the breaking changes database and provides information about the breaking change and additional instructions to migrate from Strapi v4 to Strapi 5.
重大变更描述
🌐 Breaking change description
在 Strapi v4 中
用户可能会创建自定义端点并使用 ctx 对象处理文件:
🌐 A user might create custom endpoints and handle files with the ctx object:
const endpoint = (ctx) => {
ctx.request.files.fileName.path
ctx.request.files.fileName.name
ctx.request.files.fileName.type
}
在 Strapi 5 中
用户仍然可以使用 ctx 对象创建自定义端点并处理文件,但属性名称有所不同:
🌐 A user might still create custom endpoints and handle files with the ctx object, but the property names are different:
const endpoint = (ctx) => {
ctx.request.files.fileName.filepath
ctx.request.files.fileName.originalFilename
ctx.request.files.fileName.mimetype
}
迁移
🌐 Migration
本节重新组合了有关引入的重大更改的有用说明和程序。
🌐 This section regroups useful notes and procedures about the introduced breaking change.
注意
🌐 Notes
- 官方 `koa-body` 文档列出了变更。
- 官方 `formidable` 文档列出了更改。
手动操作
🌐 Manual procedure
用户需要手动更新他们自定义代码中使用的属性,可参考官方 `koa-body` 和 `formidable` 文档。
🌐 Users need to manually update the properties used in their custom code, referring to the official `koa-body` and `formidable` documentations.