1.3.2 • Published 6 months ago

strapi-provider-upload-ipfs-free v1.3.2

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

Strapi Provider Upload IPFS Free

IPFS (Filebase, Pinata, 4Everland, Web3, Lighthouse) provider for Strapi uploads.

Installation

# using yarn
yarn add strapi-provider-upload-ipfs-free

# using npm
npm install strapi-provider-upload-ipfs-free --save

Image Compression

When a picture is detected, you can enable compression and use basharp to output the picture in webp format.

Providers Configuration

./config/plugins.js

module.exports = ({ env }) => ({
  // ...
  upload: {
    config: {
      provider: "strapi-provider-upload-ipfs-free",
      providerOptions: {
        providers: {
          filebase: [{
            // https://console.filebase.com/keys
            key: env("FILEBASE_KEY"),
            secret: env("FILEBASE_SECRET"),
            bucket: env("FILEBASE_BUCKET"),
          }],
          pinata: [{
            // https://app.pinata.cloud/keys
            key: env("PINATA_KEY"),
            secret: env("PINATA_KEY"),
          }],
          everland: [{
            // https://docs.4everland.org/storage/bucket/s3-compatible-api
            key: env("EVERLAND_KEY"),
            secret: env("EVERLAND_SECRET"),
            bucket: env("EVERLAND_BUCKET"),
          }],
          web3: [{
            // https://web3.storage/tokens/
            token: env("WEB3_TOKEN"),
          }],
          lighthouse: [{
            // https://files.lighthouse.storage/dashboard/apikey
            token: env("LIGHTHOUSE_TOKEN"),
          }],
        },
        options: {
          default: 'filebase',
          random: false,
          compression:  {
            enabeld: false,
            quality: 70,
          }
        }
      },
    },
  },
  // ...
});

.env

FILEBASE_KEY=""
FILEBASE_SECRET=""
FILEBASE_BUCKET=""

PINATA_KEY=""
PINATA_SECRET=""

EVERLAND_KEY=""
EVERLAND_SECRET=""
EVERLAND_BUCKET=""

WEB3_TOKEN=""

LIGHTHOUSE_TOKEN=""

options params

VariableTypeDescriptionRequiredDefault
defaultstringSpecify to select one of config providernoweb3
randombooleanrandomly choose one of config providernofalse
compression.enbaledbooleanWhether to enable image compression and convert it to webpnofalse
compression.qualitynumberImage Compression Qualityno70

Filebase Variable [ tutorial ]

VariableTypeDescriptionRequired
keystringFilebase access keyyes
secretstringFilebase access secretyes
bucketstringFilebase bucket nameyes

Pinata Variable

VariableTypeDescriptionRequired
keystringPinata access keyyes
secretstringPinata access secretyes

4Everland Variable

VariableTypeDescriptionRequired
keystring4Everland access keyyes
secretstring4Everland access secretyes
bucketstring4Everland bucket nameyes

Web3 Variable

VariableTypeDescriptionRequired
tokenstringWeb3 Storage API Tokenyes

Lighthouse Variable

VariableTypeDescriptionRequired
tokenstringLighthouse Storage API Tokenyes

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:",
            "dl.airtable.com",
            "*.ipfs.dweb.link", // ipfs.tech
            "*.ipfs.cf-ipfs.com", // cloudflare.com
            "*.ipfs.w3s.link", // web3.storage
          ],
          "media-src": [
            "'self'",
            "data:",
            "blob:",
            "dl.airtable.com",
            "*.ipfs.dweb.link", // ipfs.tech
            "*.ipfs.cf-ipfs.com", // cloudflare.com
            "*.ipfs.w3s.link", // web3.storage
          ],
          upgradeInsecureRequests: null,
        },
      },
    },
  },
  // ...
];

Links


1.3.2

6 months ago

1.3.1

11 months ago

1.3.0

11 months ago

1.2.2

11 months ago

1.2.1

11 months ago

1.2.0

11 months ago

1.1.3

11 months ago

1.1.2

11 months ago

1.1.1

11 months ago

1.1.0

11 months ago

1.0.7

11 months ago

1.0.6

11 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago