Socket
Socket
Sign inDemoInstall

@os-team/yc-storage

Package Overview
Dependencies
9
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @os-team/yc-storage

Yandex Cloud Object Storage API. All methods described in the official documentation are implemented (buckets, objects, multipart upload, static website hosting, CORS, lifecycles, ACL, bucket policy).


Version published
Maintainers
1
Install size
1.26 MB
Created

Readme

Source

@os-team/yc-storage NPM version BundlePhobia

Yandex Cloud Object Storage API. All methods described in the official documentation are implemented (buckets, objects, multipart upload, static website hosting, CORS, lifecycles, ACL, bucket policy).

Usage

Install the package using the following command:

yarn add @os-team/yc-storage

Simple example

import YandexStorage from '@os-team/yc-storage';

const yandexStorage = new YandexStorage({
  accessKeyId: 'accessKeyId',
  secretAccessKey: 'secretAccessKey',
  region: 'ru-central1-a',
});

const res = await yandexStorage.bucket.listObjects({
  bucket: 'my-bucket',
});

To get an access key ID and a secret access key, create a new service account (e.g. with the name of your app), click the line with its name, click Create new key and Create static access key.

Uploading a file

To upload a file using a buffer, use the object.upload method, which uploads the entire file at once. This method is recommended, if the file size is up to 100 MB.

const res = await yandexStorage.object.upload({
  bucket: 'my-bucket',
  key: 'image.png',
  body: fs.readFileSync(filePath), // Must be a buffer
  contentType: 'image/png',
});

To upload a file using a stream, use the multipart.upload method, which uploads the file in parts (see more the general procedure for multipart upload). This method is recommended, if the file size exceeds 100 MB.

const res = await yandexStorage.multipart.upload({
  bucket: 'testabc',
  key: 'big.png',
  body: fs.createReadStream(filePath), // Must be a stream
  contentType: 'image/png',
});

It makes no sense to describe all the methods in this README, because the library fully implements all the methods of the Yandex Cloud Storage API described in the official documentation.

FAQs

Last updated on 23 Feb 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc