@sumor/storage

1.0.4 • Public • Published

storage

A Sumor Cloud Tool.
More Documentation

This is a lightweight storage library for Node.JS. It can connect to various storage services, such as Aliyun OSS

CI Test Coverage Audit

Installation

npm i @sumor/storage --save

Prerequisites

Node.JS version

Require Node.JS version 18.x or above

require Node.JS ES module

As this package is written in ES module, please change the following code in your package.json file:

{
  "type": "module"
}

Usage

Import

import { Storage } from '@sumor/storage'

const storage = new Storage(config)

Config format

example for aliyun OSS

{
  "type": "aliyunOSS",
  "accessKeyId": "xxxx",
  "accessKeySecret": "xxx",
  "region": "oss-us-west-1",
  "bucket": "sumor-cloud"
}

Put

put content support text, buffer, stream

import { Storage } from '@sumor/storage'

const storage = new Storage(config)

const filename = 'demo.txt'
const content = 'Hello World'

const result = await storage.put(filename, content)

Get

import { Storage } from '@sumor/storage'

const storage = new Storage(config)

const filename = 'demo.txt'

const result = await storage.get(filename)

Delete

import { Storage } from '@sumor/storage'

const storage = new Storage(config)

const filename = 'demo.txt'

const result = await storage.delete(filename)

Dependents (0)

Package Sidebar

Install

npm i @sumor/storage

Weekly Downloads

47,960

Version

1.0.4

License

MIT

Unpacked Size

14.9 kB

Total Files

10

Last publish

Collaborators

  • ohnow