isuvorov / strapi-provider-upload-ts-minio

Minio Server upload file provider for Strapi.
MIT License
12 stars 4 forks source link

Conventional Commits

strapi-provider-upload-ts-minio

This upload provider for Strapi uses the JavaScript Minio.Client to upload files to a (self hosted) instance of Minio.

It's compatible with the the strapi 3.1.1.

Installation and basic usage

npm i strapi-provider-upload-ts-minio

Add in config/plugins.js something like this:

Minimal config

// File: ./config/plugins.js

module.exports = ({ env }) => ({
  upload: {
    provider: 'ts-minio',
    providerOptions: {
      accessKey: env('MINIO_ACCESS_KEY'),
      secretKey: env('MINIO_SECRET_KEY'),
      bucket: env('MINIO_BUCKET'),
      endPoint: env('MINIO_ENDPOINT'),
    },
  },
});

Advanced config

// File: ./config/plugins.js

module.exports = ({ env }) => ({
  upload: {
    provider: 'ts-minio',
    providerOptions: {
      accessKey: env('MINIO_ACCESS_KEY'),
      secretKey: env('MINIO_SECRET_KEY'),
      bucket: env('MINIO_BUCKET'),
      internalEnpoint: env('MINIO_INTERNAL_ENDPOINT'), 
      externalEnpoint: env('MINIO_EXTERNAL_ENDPOINT'), 
      port: parseInt(env('MINIO_PORT'), 10) || 9000,
    },
  },
});

Run Strapi with env:

Run Strapi with env:

MINIO_INTERNAL_ENDPOINT=https://play.minio.io:1234 \
MINIO_EXTERNAL_ENDPOINT=https://cdn.minio.io \
MINIO_ACCESS_KEY=username \
MINIO_SECRET_KEY=Q.ixuW@JGV!*ENWH9Ut62B!3 \
MINIO_BUCKET=bucketname \
  npm run start

From the providers list select Minio Server

NOTE: bucket policy must be set to allow your file to be readable. (just set it to: prefix *, readonly)

Config

There is only a couple of settings need to be provided to make it work. The following config settings are available:

Config Label Internal Name Value
Access API Token accessKey string
Secret Access Token secretKey string
Bucket bucket string
Endpoint endPoint/endpoint string
Internal Endpoint internalEndpoint string
External Endpoint externalEndpoint string
Port port string
SSL useSSL string(true for ssl, anything else for false)
Folder folder string

Thanks for examples

Links

Write me and I help you if you have any problems

Sponsorship

Contributors ✨


Igor Suvorov

💬 💻 🎨 📖 💡 🤔 👀 ⚠️ ️️️️♿️

Thanks goes to these wonderful people (emoji key):

License

This project is licensed under the MIT License - see the MIT License file for details