msoler75 / strapi-provider-upload-multiple-provider

Allow multiple upload providers in strapi
GNU General Public License v3.0
7 stars 11 forks source link

Doesn't work with Strapi v4 #3

Open ciriousjoker opened 1 year ago

ciriousjoker commented 1 year ago

Error message:

error: Could not load upload provider "multiple-provider".
Error: Cannot find module 'multiple-provider'
Require stack:
- /node_modules/@strapi/plugin-upload/server/register.js
- /node_modules/@strapi/plugin-upload/server/index.js
- /node_modules/@strapi/plugin-upload/strapi-server.js
- /node_modules/@strapi/utils/lib/import-default.js
- /node_modules/@strapi/utils/lib/index.js
- /node_modules/@strapi/strapi/lib/Strapi.js
- /node_modules/@strapi/strapi/lib/index.js
- /node_modules/@strapi/strapi/lib/commands/transfer/utils.js
- /node_modules/@strapi/strapi/bin/strapi.js
ciriousjoker commented 1 year ago

@jimrowetpa has a fork which works great (apart from a missing dependency which I created a PR for), maybe this can be merged?

spshukla commented 1 year ago

@ciriousjoker I am also trying to use the same plugin to have multiple providers (basically different bucket for different mime types) but it's not uploading any file to S3. It's just uploading the files to local. I am using the Strapi V4 and not seeing any error on the console. Can you please help me on this?

spshukla commented 1 year ago

@ciriousjoker Please find the plugins configuration

module.exports = ({ env }) => ({
  upload: {
          logger:console,
          provider: "multiple-provider",
          providerOptions: {
                selectProvider(file) {
  if(file.name.match(/\.(jpe?g|png|webp|svg)$/))
    return 'images'
  else
    return 'default'
},
                  providers:{
                    'images':{
  provider: 'aws-s3',
  options: {
  providerOptions :{
    accessKeyId: env('AWS_ACCESS_KEY_ID'),
    secretAccessKey: env('AWS_ACCESS_SECRET'),
    region: env('AWS_REGION'),
    params: {
        Bucket: '<bucket-name>',
            cdn: env('AWS_CDN_DOMAIN'),
    },
          logger: console,
    },
    actionOptions: {
    upload: {},
    uploadStream: {},
    delete: {},
  }
  }

                    },
                          'default':{
                           provider: 'aws-s3',
  options: {
  providerOptions :{
    accessKeyId: env('AWS_ACCESS_KEY_ID'),
    secretAccessKey: env('AWS_ACCESS_SECRET'),
    region: env('AWS_REGION'),
    params: {
        Bucket: '<bucket-name>',
            cdn: env('AWS_CDN_DOMAIN'),
    },
          logger: console,
    },
    actionOptions: {
    upload: {},
    uploadStream: {},
    delete: {},
  }
  }

                          }

                  }

          }
  },
});
spshukla commented 1 year ago
ciriousjoker commented 1 year ago

No idea how to help you sorry

jimrowetpa commented 1 year ago

@spshukla My config of the providers looks different. Not sure why but this was working a few months ago. Perhaps changes to Stapi?

config: {
    provider: 'strapi-provider-upload-multiple-provider',
    providerOptions: {
        selectProvider(file) {
            if (file.name.match(/\.(mp4|mov|wmv|avi|mkv|webm)$/))
                return 'video'
            else
                return 'default'
        },
        providers: {
            'default': {
                provider: '@strapi/provider-upload-aws-s3',
                options: {
                    accessKeyId: env('AWS_ACCESS_KEY_ID'),
                    secretAccessKey: env('AWS_ACCESS_SECRET'),
                    region: env('AWS_REGION'),
                    params: {
                        Bucket: env('AWS_BUCKET'),
                    },
                },
                actionOptions: {
                    upload: {},
                    uploadStream: {},
                    delete: {},
                }
            },
            'video': {
                provider: 'strapi-provider-upload-vimeo',
                options: {
                    accessToken: env('VIMEO_ACCESS_TOKEN'),
                    clientSecret: env('VIMEO_CLIENT_SECRET'),
                    clientId: env('VIMEO_CLIENT_ID'),
                    folderId: env('VIMEO_FOLDER_ID')
                }
            }
        }
    }
}