strapi-provider-upload-local-extra
This Strapi upload
provider has extra options to customize how uploads should be stored on the local file system.
Precondition
This provider plugin requires a strapi version >4.0.0
Installation
npm install strapi-provider-upload-local-extra
Configuration
Strapi
This provider plugin needs to be configured in this file: ./config/plugins.js
.
For example:
module.exports = ({ env }) => ({
upload: {
config: {
provider: 'strapi-provider-upload-local-extra',
providerOptions: /** @type {UploadLocalExtraOptions} */({
/**
* @param {LocalProperties} props
* @returns string
*/
getLocalPath: props => `uploads/${props.hash}${props.ext}`
})
}
}
});
@type {...}
is optional, when used editors can provide code completion for an easy configuration.
UploadLocalExtraOptions
Property | Type | Description |
---|---|---|
sizeLimit | number |
Does not write the file to disk, when the file is too large. Throws a PayloadTooLargeError. Default: 1000000 |
getLocalPath | LocalProperties => string |
The public directory to store the files. Default: Uses the strapi public directory. |
LocalProperties
Property | Type | Description |
---|---|---|
file | StrapiFile |
The original Strapi file object passed to the update and delete function. |
hash | string |
The file hash. Same as props.file.hash . |
ext | string |
The file extendsion. Same as props.file.ext . |
uniqueId | string |
A unique id with 16 characters (0-9, A-Z, a-z) using nanoid |
sizeName | string |
The image size as name of ('thumbnail', 'small', 'medium', 'large') |