Socket
Book a DemoInstallSign in
Socket

@chcaa/strapi-provider-upload-local-configurable

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chcaa/strapi-provider-upload-local-configurable

Configurable strapi local upload provider with configurable root-dir and partitioning

1.0.5
latest
npmnpm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

@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

FAQs

Package last updated on 03 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.