Code Monkey home page Code Monkey logo

strapi-provider-upload-firebase-storage's Introduction

@purwasadr/strapi-provider-upload-firebase-storage

Installation

# using yarn
yarn add @purwasadr/strapi-provider-upload-firebase-storage

# using npm
npm install @purwasadr/strapi-provider-upload-firebase-storage

Configuration

  • provider defines the name of the provider
  • providerOptions is passed down during the construction of the provider.
  • actionOptions is passed directly to the parameters to each method respectively. You can find the complete list of upload options and delete options

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

module.exports = ({ env }) => ({
  // ...
  upload: {
    config: {
      provider: '@purwasadr/strapi-provider-upload-firebase-storage',
      providerOptions: {

        // Can be pathString or object
        serviceAccount: env('STORAGE_SERVICE_ACCOUNT'),  

        // Your bucket name. example : if the bucket URL displayed in the Firebase console 
        // is gs://bucket-name.appspot.com, pass the string bucket-name.appspot.com
        bucketName: env('STORAGE_BUCKET_NAME'),

        // Other options in initializeApp
        options: {},

        // Use custom bucket if any
        customBucket: env('STORAGE_CUSTOM_BUCKET'),  
      },
      actionOptions: {

        // Upload options see : https://googleapis.dev/nodejs/storage/latest/global.html#CreateWriteStreamOptions
        upload: {},

        // Delete options see : https://googleapis.dev/nodejs/storage/latest/File.html#delete
        delete: {},
      },
    },
  },
  // ...
});

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: {
        useDefaults: true,
        directives: {
          'connect-src': ["'self'", 'https:'],
          'img-src': [
            "'self'",
            'data:',
            'blob:',
            'storage.googleapis.com',
          ],
          'media-src': [
            "'self'",
            'data:',
            'blob:',
            'storage.googleapis.com',
          ],
          upgradeInsecureRequests: null,
        },
      },
    },
  },
  // ...
];

strapi-provider-upload-firebase-storage's People

Contributors

purwasadr avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.