Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work with Strapi v4 #3

Open
ciriousjoker opened this issue Feb 21, 2023 · 6 comments
Open

Doesn't work with Strapi v4 #3

ciriousjoker opened this issue Feb 21, 2023 · 6 comments

Comments

@ciriousjoker
Copy link

ciriousjoker commented Feb 21, 2023

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
Copy link
Author

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

@spshukla
Copy link

@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
Copy link

@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
Copy link

@ciriousjoker
Copy link
Author

No idea how to help you sorry

@jimrowetpa
Copy link

jimrowetpa commented Mar 14, 2023

@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')
				}
			}
		}
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants