Strapi saving files to Yandex Object Storage

Perhaps you have already tried Strapi and you even liked it so much that you decided to deploy on one of the servers.





For example, I did deploy on a VPS with Node, nginx, pm2. Since VPS usually has meager storage capabilities, you want to store all your stuff on one of the modern storages.





Strapi designed the Amazon S3 backet connector for us. This plugin is already included in the standard strapi repository, and was previously featured as a community plugin.





You can watch how to connect an Amazon S3 bucket here: a

video from Alex

(today the configuration files need to be written a little differently - but the general outline is preserved).





In this article, we will consider connecting Yandex Object Storage. First, of course, you need to register on Yandex cloud. After that, select Object Storage in the management console.





Click on the yellow button "Create bucket" and fill in the fields as shown in the picture - i.e. set public access to read and to the list of objects, the storage class is standard.





After you click on the "Create bucket" button, you will see it in the list of buckets:





Strapi. ( ) ( ) - default - .





" " - ( )





- , .





" " " ", . - :





- .







npx create-strapi-app strapi-yandex-cloud --quickstart







Strapi strapi-yandex-cloud . .





, - strapi-yandex-cloud :

npm i -S strapi-provider-upload-aws-s3







- . onfig/plugins.js ( plugins.js config) :





module.exports = ({ env })=>({
  upload: {
    provider: 'aws-s3',
    providerOptions: {
      endpoint: 'https://storage.yandexcloud.net',
      accessKeyId: env('AWS_ACCESS_KEY_ID'),
      secretAccessKey: env('AWS_ACCESS_SECRET'),
      region: env('AWS_REGION'),
      params: {
        Bucket: env('AWS_BUCKET'),
      },
    },
  },
});
      
      



. .env :





HOST=0.0.0.0
PORT=1337

AWS_ACCESS_KEY_ID=pg2ywMziH_9zeZfA7t3w
AWS_ACCESS_SECRET="aTiO354YNpnO9zKjqBiP1U3nm3F3CoXGLYcldZBC"
AWS_REGION="ru-central1"
AWS_BUCKET="strapi-backet-test"
      
      



strapi-backet-test - , , - , .





!

- npm run develop.

strapi Media Library, .





cloud.yandex.ru :





. , Strapi .





Media Library , , pdf . Strapi Rest API Media Library.





P.S. , .








All Articles