Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions docs/developer-docs/latest/development/providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ module.exports = {
delete(file) {
// delete the file in the provider
},
checkFileSize(file, { sizeLimit }) {
// implement your own file size limit logic
// there is a default logic in place if this
// method is not implemented
},
};
},
};
Expand Down
6 changes: 2 additions & 4 deletions docs/developer-docs/latest/plugins/upload.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export default [

</code-group>

In addition to the middleware configuration, you can pass the `sizeLimit`, which is an integer in bytes, in the `providerOptions` of the [plugin configuration](/developer-docs/latest/setup-deployment-guides/configurations/optional/plugins.md) in `./config/plugins.js`:
In addition to the middleware configuration, you can pass the `sizeLimit`, which is an integer in bytes, in the [plugin configuration](/developer-docs/latest/setup-deployment-guides/configurations/optional/plugins.md) in `./config/plugins.js`:

<code-group>

Expand All @@ -148,9 +148,7 @@ module.exports = {
// ...
upload: {
config: {
providerOptions: {
sizeLimit: 250 * 1024 * 1024 // 256mb in bytes
}
sizeLimit: 250 * 1024 * 1024 // 256mb in bytes
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ The `./config/server.js` file can include the following parameters:
| `cron.tasks` | Declare [CRON jobs](/developer-docs/latest/setup-deployment-guides/configurations/optional/cronjobs.md) to be run at specific dates. | object | |
| `dirs` | Path configuration of different directories Strapi uses. | object | |
| `dirs.public` | Customize the path of the public folder. | string | `./public` |
| `webhooks.populateRelations` | For backward compatibility reasons, the default value is `true`, but the recommended value is `false` to avoid performance issues when having many relations. If you need populated relations in your webhook, we recommend doing a separate query in your webhook listener to fetch the entity only with the necessary data. | boolean | `true` |

## Configurations

Expand Down Expand Up @@ -130,6 +131,7 @@ export default ({ env }) => ({
},
});
```

</code-block>
</code-group>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Migrations are necessary when upgrades to Strapi include breaking changes. The m
- [Migration guide from 4.3.6 to 4.3.8](migration-guides/v4/migration-guide-4.3.6-to-4.3.8.md)
- [Migration guide from 4.4.3 to 4.4.5](migration-guides/v4/migration-guide-4.4.3-to-4.4.5.md)
- [Migration guide from 4.4.5 to 4.5.1](migration-guides/v4/migration-guide-4.4.5-to-4.5.1.md)
- [Migration guide from 4.5.1+ to 4.6.1](migration-guides/v4/migration-guide-4.5.1-to-4.6.1.md)

## v3 to v4 migration guides

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
---
title: Migrate from 4.5.1+ to 4.6.1 - Strapi Developer Docs
description: Learn how you can migrate your Strapi application from 4.5.1+ to 4.6.1.
canonicalUrl: https://docs.strapi.io/developer-docs/latest/update-migration-guides/migration-guides/v4/migration-guide-4.5.1-to-4.6.1.html
---

# v4.5.1+ to v4.6.1 migration guide

The Strapi v4.5.1+ to v4.6.1 migration guide upgrades v4.5.1+ to v4.6.1. We introduced a configuration for webhooks to receive populated relations. Also, this migration guide is needed for all users who were limiting media size for the local upload provider.

The migration guide consists of:

- Upgrading the application dependencies
- Changing the webhooks configuration (optional)
- Updating the local upload provider `sizeLimit`
- Reinitializing the application

## Upgrading the application dependencies to 4.6.1

:::prerequisites
Stop the server before starting the upgrade.
:::

1. Upgrade all of the Strapi packages in `package.json` to `4.6.1`:

```json
// path: package.json

{
// ...
"dependencies": {
"@strapi/strapi": "4.6.1",
"@strapi/plugin-users-permissions": "4.6.1",
"@strapi/plugin-i18n": "4.6.1"
// ...
}
}
```

2. Save the edited `package.json` file.

3. Run either `yarn` or `npm install` to install the new version.

::: tip
If the operation doesn't work, try removing your `yarn.lock` or `package-lock.json`. If that doesn't help, remove the `node_modules` folder as well and try again.
:::

## Changing the webhooks configuration (optional)

By default, and for backward compatibility reasons, webhooks will receive the entity with its relations populated again. We do recommend to disable this behavior if you were not using it, as it may cause performance issues when having many relations. If you need populated relations in your webhook, we recommend doing a separate query in your webhook listener to fetch the entity only with the necessary data.

If you want to change this behavior, you can do so by editing the `./config/server.js` file (or `./config/server.ts` if you are using TypeScript) and add the following configuration:

```jsx
'use strict';

module.exports = ({ env }) => ({
host: env('HOST', '0.0.0.0'),
port: env.int('PORT', 1337),
url: 'http://localhost:1337',
webhooks: {
// Add this to not receive populated relations in webhooks
populateRelations: false,
},
});
```

With this, you will no longer receive populated relations in webhooks, and **response times on the Content Manager will be shorter**.

You can see more of the available configuration options in the [server configuration documentation](/developer-docs/latest/setup-deployment-guides/configurations/required/server.md).

## Updating the sizeLimit provider configuration

This step is only required if you were using the [`sizeLimit` configuration](/developer-docs/latest/plugins/upload.md#max-file-size) for your upload provider.

:::caution
The documentation required the `sizeLimit` to be in bytes, but it was actually in kilobytes. This is now fixed, and the limit will be interpreted as bytes.

If you, for some reason, were limiting the file size to kilobytes, you should update the value to be in bytes.
:::

We recommend to move the `sizeLimit` outside the provider options like the following, as it will be deprecated in the next major version.
<code-group>

<code-block title="JAVASCRIPT">

```js
// path: ./config/plugins.js

module.exports = {
// ...
upload: {
config: {
sizeLimit: 250 * 1024 * 1024 // Now
providerOptions: {
sizeLimit: 250 * 1024 * 1024 // Before
}
}
}
};
```

</code-block>

<code-block title="TYPESCRIPT">

```js
// path: ./config/plugins.ts

export default {
// ...
upload: {
config: {
sizeLimit: 250 * 1024 * 1024 // Now
providerOptions: {
sizeLimit: 250 * 1024 * 1024 // Before
}
}
}
};
```

</code-block>

</code-group>

To change the script:

1. In the `./config/plugins.js` file, identify the upload configuration if you have one.
2. (_optional_) If you have a `sizeLimit`, move it one level above `providerOptions`.

!!!include(developer-docs/latest/update-migration-guides/migration-guides/v4/snippets/Rebuild-and-start-snippet.md)!!!