@sumor/storage
v1.0.4
Published
It can connect to various storage services, such as Aliyun OSS
Downloads
241,735
Readme
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
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)