@chcaa/strapi-provider-upload-local-configurable
v1.0.5
Published
Configurable strapi local upload provider with configurable root-dir and partitioning
Downloads
7
Readme
@chcaa/strapi-provider-upload-local-configurable
A configurable local file system upload provider for strapi with the possibilities to configure:
- base url
- file root dir
- file partitioning into sub-dirs
- and more ...
installation
npm install @chcaa/strapi-provider-upload-local-configurable --save
Configuration
the following settings can be set in ./config/plugins.js
. The provider
, rootDir
and baseUrl
are required. The
rest of the values shown below is the default values.
module.exports = ({ env }) => ({
// ...
upload: {
config: {
provider: '@chcaa/strapi-provider-upload-local-configurable',
providerOptions: {
rootDir: undefined, // an absolute path or path relative to strapis ./public/ dir
urlPath: undefined, // the url-path where files are located e.g. /static/files
sizeLimit: 100000,
partition: { // set depth to a number higher than zero e.g. 2 to create 2 levels of sub-dirs
depth: 0, // a value > 0 will enable partitioning
nameLength: 3, // the name length of each sub-dir
},
fileNamePrefixToSubDir: [ // use the file-name prefix as a sub-dir
"thumbnail_",
"small_",
"medium_",
"large_"
]
},
},
},
// ...
});
The sizeLimit
unit is in bytes. 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. Read more here
Changing the Router Url Path
When setting rootDir
and urlPath
to something other than the standard "uploads" dir as defined by strapi,
a change of the router pointing to the new rootDir
and/or urlPath
is required. This can be done with the
@chcaa/strapi-static-file-route plugin