0.0.2 ā€¢ Published 3 years ago

strapi-provider-upload-matrix v0.0.2

Weekly downloads
6
License
MIT
Repository
github
Last release
3 years ago

npm.io


Usage

To install latest version use NPM.

npm install --save strapi-provider-upload-matrix

Overview

Strapi has great support for plugins and upload providers, but you can register only one upload provider. Let's say you want to deploy images to image service and other files to file service. This provider will help you.

Documentation

  1. Install provider.
  2. Install other upload providers.
  3. Edit configuration.

    We are going to setup 2 providers (ImageKit and S3).

    • Images will use imagekit according to extensions (png, jpg, jpeg, svg, webp, gif, tif, mp4, webm, mov, swf, pdf)
    • Other files will use aws-s3 according to fallback

    {strapi}/config/plugins.js

    module.exports = ({ env }) => ({
        upload: {
            provider: 'matrix',
            providerOptions: {
            resolvers: [
                // ImageKit
                // Images, videos
                {
                    id: 'images',
                    test: {
                        ext: ['png', 'jpg', 'jpeg', 'svg', 'webp', 'gif', 'tif', 'mp4', 'webm', 'mov', 'swf', 'pdf'],
                    },
                    use: {
                        provider: "imagekit",
                        providerOptions: {
                        publicKey: env("IMAGEKIT_PUBLIC_KEY"),
                        privateKey: env("IMAGEKIT_PRIVATE_KEY"),
                        urlEndpoint: env("IMAGEKIT_URL"),
                            params: {
                                folder: env("IMAGEKIT_FOLDER"),
                            }
                        }
                    }
                },
                // AWS S3
                // Fallback
                {
                    id: 'misc',
                    test: '*',
                    use: {
                        provider: 'aws-s3',
                        providerOptions: {
                        accessKeyId: env('AWS_ACCESS_KEY_ID'),
                        secretAccessKey: env('AWS_ACCESS_SECRET'),
                        region: env('AWS_REGION'),
                            params: {
                                Bucket: env('AWS_BUCKET'),
                            },
                        }
                    },
                },
            ]
            },
        }
    });
  4. Profit šŸš€

Development


Consider to support f3l1x. Also thank you for using this package.