Skip to main content

不再支持在创建条目时上传文件

¥Upload a file at entry creation is no longer supported

在 Strapi 5 中,创建条目时无法上传文件,因此应分两步完成。

¥In Strapi 5, it is not possible to upload a file while creating an entry, so this should be done in 2 steps.

此页面是 重大变更数据库 的一部分,提供有关重大更改的信息以及从 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.

\🔌 此重大更改是否会影响插件?\
\🤖 此重大更改是否由 codemod 自动处理?\

重大更改描述

¥Breaking change description

在 Strapi v4 中

¥In Strapi v4

可以在创建条目时上传文件,如 针对 Strapi v4 记录

¥It was possible to upload a file while creating an entry, as documented for Strapi v4.

在 Strapi 5 中

¥In Strapi 5

你必须先上传文件,然后使用创建的文件 ID 创建条目。

¥You must upload the file first, and then create the entry with the created file id.

迁移

¥Migration

本节重新组合了有关引入的重大更改的有用说明和程序。

¥This section regroups useful notes and procedures about the introduced breaking change.

迁移程序

¥Migration procedure

用户必须更新其自定义代码,首先发送 /api/upload/,然后使用创建的文件 ID 创建带有 /api 处对 REST API 进行 POST 调用 的条目。

¥Users must update their custom code, first sending a POST call to the Upload API at /api/upload/, then creating an entry with a POST call to the REST API at /api with the created file id.