Code Monkey home page Code Monkey logo

strapi-provider-upload-yandex-cloud's Introduction

Strapi Upload Provider for Yandex.Cloud Object Storage

Yandex.Cloud: https://cloud.yandex.com/en/services/storage

Docs: https://cloud.yandex.com/en/docs/storage/

Pre-install: create Yandex.Cloud account and a bucket in Object storage.

Parameters

  • YANDEX_CLOUD_ACCESS_KEY_ID - key ID (example: pg2ywMziH_9zeZfA7t3w)
  • YANDEX_CLOUD_ACCESS_SECRET - key secret (example: aTiO354YNpnO9zKjqBiP1U3nm3F3CoXGLYcldZBC)
  • YANDEX_CLOUD_REGION - bucket region (example: ru-central1)
  • YANDEX_CLOUD_BUCKET - bucket name (example: strapi-bucket-test)

Example

0️⃣

Create Strapi project (docs): npx create-strapi-app strapi-yandex-cloud-project --quickstart.

After successfully creating the project stop the dev server: CTRL + C.

1️⃣

Install upload plugin: npm i -S strapi-provider-upload-yandex-cloud.

Note: Be sure that you are in a folder with your Strapi project: cd strapi-yandex-cloud-project.

After successful installation your package.json file will have a code:

"dependencies": {
    ...
    "strapi": "3.6.5",
    "strapi-provider-upload-yandex-cloud": "1.1.0",
    ...
  },

2️⃣

Go to code editor to your project folder and create config file for your bucket: ./config/plugins.js (file plugins.js in config folder in the root of your Strapi project) with the code:

module.exports = ({ env }) => ({
  upload: {
    provider: 'yandex-cloud',
    providerOptions: {
      endpoint: 'https://storage.yandexcloud.net',
      accessKeyId: process.env.YANDEX_CLOUD_ACCESS_KEY_ID,
      secretAccessKey: process.env.YANDEX_CLOUD_ACCESS_SECRET,
      region: process.env.YANDEX_CLOUD_REGION,
      params: {
        Bucket: process.env.YANDEX_CLOUD_BUCKET,
        CacheControl: "public, max-age=864000"
      }
    }
  }
});

NOTE You can pass aws s3 params in params object, such as CacheControl, ContentEncoding, etc. More params at: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html

3️⃣

Create a .env file in the root of your Strapi project.

Example of .env.local:

HOST=0.0.0.0
PORT=1337

YANDEX_CLOUD_ACCESS_KEY_ID=pg2ywMziH_9zeZfA7t3w
YANDEX_CLOUD_ACCESS_SECRET=aTiO354YNpnO9zKjqBiP1U3nm3F3CoXGLYcldZBC
YANDEX_CLOUD_REGION=ru-central1
YANDEX_CLOUD_BUCKET=strapi-backet-test

4️⃣

Test the new uploader.

  1. Start Strapi dev server: npm run develop.

  2. Open Strapi media library in a browser and upload a test image.

strapi-provider-upload-yandex-cloud's People

Contributors

teinett avatar j2only 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.