1.0.2 • Published 3 years ago

strapi-provider-upload-r2 v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

Strapi Provider Upload R2

A Strapi plugin for uploading files to Cloudflare R2.

Installation

Install strapi-provider-upload-r2 with npm

npm i strapi-provider-upload-r2

Environment Variables

To run this project, you will need to add the following environment variables to your .env file

R2_ACCOUNT_ID

R2_ACCESS_KEY_ID

R2_SECRET_ACCESS_KEY

R2_BUCKET

R2_PUBLIC_URL

Setup

config/plugins

module.exports = ({ env }) => ({
  // ...
  upload: {
    config: {
      provider: "strapi-provider-upload-r2",
      providerOptions: {
        accessKeyId: env("R2_ACCESS_KEY_ID"),
        secretAccessKey: env("R2_SECRET_ACCESS_KEY"),
        bucket: env("R2_BUCKET"),
        accountId: env("R2_ACCOUNT_ID"),
        publicUrl: env("R2_PUBLIC_URL"),
      },
    },
  },
  // ...
})

config/middlewares

 // ...
  {
    name: "strapi::security",
    config: {
      contentSecurityPolicy: {
        useDefaults: true,
        directives: {
          "connect-src": ["'self'", "https:"],
          "img-src": [
            "'self'",
            "data:",
            "blob:",
            "dl.airtable.com",
            env("R2_PUBLIC_URL").replace(/^https?:\/\//, ""),
          ],
          "media-src": [
            "'self'",
            "data:",
            "blob:",
            "dl.airtable.com",
            env("R2_PUBLIC_URL").replace(/^https?:\/\//, ""),
          ],
          upgradeInsecureRequests: null,
        },
      },
    },
  },
  // ...

Appendix

Allow public access to the Bucket:

https://developers.cloudflare.com/r2/data-access/public-buckets/#enable-managed-public-access-for-your-bucket

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago