npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cloudflare-upload-provider-v2

v1.1.2

Published

Strapi provider for uploading and deleting to/from Cloudflare streams and images compatible

Downloads

614

Readme

cloudflare-upload-provider-v2

Non-Official Cloudflare Images and Video Upload Provider for Strapi

This has only been tested with Strapi 4.

Installation

# using yarn
yarn add cloudflare-upload-provider-v2

# using npm
npm install cloudflare-upload-provider-v2

Configurations

Your configuration is passed down to the provider.

See the using a provider documentation for information on installing and using a provider. And see the environment variables for setting and using environment variables in your configs.

Provider Configuration

./config/plugins.js

module.exports = ({ env }) => ({
  // ...
  upload: {
    config: {
      provider: "cloudflare-upload-provider-v2",
      providerOptions: {
        accountId: env("STRAPI_UPLOAD_CLOUDFLARE_ACCOUNT_ID"),
        apiKey: env("STRAPI_UPLOAD_CLOUDFLARE_API_KEY"),
      },
    },
  },
  // ...
});

For the variant you can use one you have configured in Cloudflare Images. Or if not, can configure. In this example we used 'cms' as variant. Creating variants of your image is partly explained in the Cloudflare documentation. For this go to your Cloudflare Dash panel and click Images. Next click Variants. From that screen you can add a new variant. Please note that with the Fit Scale Down option your image size will keeps its original size as long as its not above the given width and height parameters.

Environment configuration

In the Provider Configuration there are the accountId and apiKey. Those environment variables should be set in the .env file . To find your Cloudflare accountId and apiKey, log into your Cloudflare dashboard and click "Images". On that page you should see "Account ID" under Developer Resources. For apiKey, if you click the "Use API" tab you'll see a link next to "API Token" to generate an apiKey. Click get started at Create Custom Token and give your token a name e.g. 'Cloudflare images Strapi'. In the permissions section after Account select item choose "Cloudflare Images" with edit permission. Next add another one and after Account select item choose "Stream" with edit permission.

./.env

STRAPI_UPLOAD_CLOUDFLARE_ACCOUNT_ID=<place your Cloudflare Account ID here>
STRAPI_UPLOAD_CLOUDFLARE_API_KEY=<place your Cloudflare apiKey here>

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:", "imagedelivery.net"],
          "media-src": ["'self'", "data:", "blob:", "imagedelivery.net"],
          upgradeInsecureRequests: null,
        },
      },
    },
  },
  // ...
];

Optional

By default Strapi comes with Responsive formats and provides large, medium and small sizes automatically which also will be uploaded to Cloudflare images. This will count through your Cloudflare images plan by the limit of the amount of images. Because the variants in cloudflare images comes included in the plan it is recommended to turn off the responsive formats. To turn this off open your Strapi admin dashboard and go to settings at global settings choose Media Library. In this screen you can turn off Responsive friendly upload and Size optimization since this is handled by Cloudflare images as well. Please note Strapi still comes with a thumbnail image variant which is also uploaded automatically to Cloudflare images.

Resources

Links