Local Upload provider
The Media Library feature is powered by a back-end server package called Upload which leverages the use of providers.
Strapi maintains 3 providers for the Media Library. The present page is about the local Upload provider installation and configuration. For other providers, please refer to the list in the Media Library page.
Installation
To install the provider, run the following command in a terminal:
- Yarn
- NPM
yarn add @strapi/provider-upload-local
npm install @strapi/provider-upload-local --save
Configuration
Providers configuration is defined in the /config/plugins file. If this file does not exist, create it first. The provider configuration accepts the following entries:
providerto define the provider name (i.e.,local)providerOptionsto define options that are passed down during the construction of the provider.
For the local Upload provider, providerOptions accepts only one parameter: sizeLimit, which must be a number. Be aware that the unit is in bytes, and the default is 1000000. When setting this value high, you should make sure to also configure the body parser middleware maxFileSize so the file can be sent and processed (see Media Library documentation for details).
The following is an example configuration:
- JavaScript
- TypeScript
module.exports = ({ env }) => ({
// ...
upload: {
config: {
provider: 'local',
providerOptions: {
sizeLimit: 100000,
},
},
},
// ...
});
export default ({ env }) => ({
// ...
upload: {
config: {
provider: 'local',
providerOptions: {
sizeLimit: 100000,
},
},
},
// ...
});
Unlike the AWS S3 and Cloudinary providers, the local Upload provider does not require special security middleware configuration. The default configuration already allows loading images and media from self.