Skip to content

msoler75/strapi-provider-upload-multiple-provider

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Strapi Upload Multiple Provider

Allow multiple upload providers in strapi (v3)

The selection of which provider to use is determined by a selectProvider function in settings with file information. Each provider is identified by keyString.

Each provider plugin need to be installed.

Installation

npm i strapi-provider-upload-multiple-provider

Use

config/plugins.js:

upload: {
  provider: "multiple-provider",
  providerOptions: {
    selectProvider(file) {
      // return some key string
    },
    providers: {
      'key1' : {
        provider: #providerName#,
        options: #providerOptions#
      },
      'key2' : {
        provider: #providerName#,
        options: #providerOptions#
      },
      ...
    }  
  }  
}

A more complete example:

config/plugins.js:

upload: {
  provider: "multiple-provider",
  providerOptions: {
    selectProvider(file) {
      if(file.name.match(/\.pdf$/))
        return 'documents'
      else if(file.name.match(/\.(jpe?g|png|webp|svg)$/))
        return 'images'
      else
        return 'default'
    },
    providers: {
      'default' : {
        provider: 'local',
      },
      'images' : {
         provider: 'google-cloud-storage',
         options: { 
           bucketName: 'mybucketimages',
           publicFiles: true,
           uniform: true,
           basePath: "",
        }
      },
      'documents': {
         provider: 'google-cloud-storage',
         options: {    
           bucketName: 'mybucketdocuments',
           publicFiles: true,
           uniform: true,
           basePath: "",
        }
      }
    }  
  }  
}

About

Allow multiple upload providers in strapi

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published