1.0.8 • Published 2 years ago
strapi-upload-supabase-provider v1.0.8
strapi-upload-supabase-provider
Resources
Links
Installation
# using yarn
yarn add strapi-upload-supabase-provider
# using npm
npm install strapi-upload-supabase-provider --saveConfiguration
providerdefines the name of the provider, in this case we must put "strapi-upload-supabase-provider".providerOptionsis passed down during the construction of the provider. (ex:new StorageClient(config)).providerOptions.apiUrlRESTful endpoint to manage your Supabase project.providerOptions.apiKeyAPI key of your Supabase project(service_role not anon).providerOptions.bucketname of your Supabase bucket.providerOptions.directorydirectory inside the bucket where you want to store your files.sizeLimitmaximum size limit for your files on bytes.
See the documentation about using a provider for information on installing and using a provider. To understand how environment variables are used in Strapi, please refer to the documentation about environment variables.
Provider Configuration
./config/plugins.js or ./config/plugins.ts for TypeScript projects:
module.exports = ({ env }) => ({
// ...
upload: {
config: {
provider: "strapi-upload-supabase-provider",
providerOptions: {
apiUrl: env("SUPABASE_API_URL"),
apiKey: env("SUPABASE_API_KEY"),
bucket: env("SUPABASE_BUCKET_NAME"),
directory: env("SUPABASE_BUCKET_DIRECTORY"),
},
sizeLimit: 1000000000,
actionOptions: {
upload: {},
uploadStream: {},
delete: {},
checkFileSize: {},
},
},
},
// ...
});Security Middleware Configuration
Due to the default settings in the Strapi Security Middleware you will need to modify the contentSecurityPolicy settings to properly see thumbnail previews in the Media Library. You should replace strapi::security string with the object bellow instead as explained in the middleware configuration documentation.
./config/middlewares.js
module.exports = [
// ...
{
name: "strapi::security",
config: {
contentSecurityPolicy: {
directives: {
"default-src": ["'self'"],
"img-src": [
"'self'",
"data:",
"blob:",
env("SUPABASE_API_URL"),
],
},
},
},
},
// ...
];