@sumor/storage
Version:
It can connect to various storage services, such as Aliyun OSS
99 lines (64 loc) • 2.05 kB
Markdown
//sumor.cloud) Tool.
[ ](https://sumor.cloud/storage)
This is a lightweight storage library for Node.JS.
It can connect to various storage services, such as Aliyun OSS
[](https://github.com/sumor-cloud/storage/actions/workflows/ci.yml)
[](https://github.com/sumor-cloud/storage/actions/workflows/ut.yml)
[](https://github.com/sumor-cloud/storage/actions/workflows/coverage.yml)
[](https://github.com/sumor-cloud/storage/actions/workflows/audit.yml)
```bash
npm i @sumor/storage --save
```
Require Node.JS version 18.x or above
As this package is written in ES module,
please change the following code in your `package.json` file:
```json
{
"type": "module"
}
```
```js
import { Storage } from '@sumor/storage'
const storage = new Storage(config)
```
example for aliyun OSS
```json
{
"type": "aliyunOSS",
"accessKeyId": "xxxx",
"accessKeySecret": "xxx",
"region": "oss-us-west-1",
"bucket": "sumor-cloud"
}
```
put content support text, buffer, stream
```js
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)
```
```js
import { Storage } from '@sumor/storage'
const storage = new Storage(config)
const filename = 'demo.txt'
const result = await storage.get(filename)
```
```js
import { Storage } from '@sumor/storage'
const storage = new Storage(config)
const filename = 'demo.txt'
const result = await storage.delete(filename)
```
A [Sumor Cloud](https: