1.0.4 • Published 12 months ago
@sumor/storage v1.0.4
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 --savePrerequisites
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)