0.1.24 • Published 2 years ago

qdp2-oss v0.1.24

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

qdp2-oss-sdk

封装ali OSS 和 MinIO 的SDK。

NOTE: ali-oss@6.16.0,minio@7.0.18

Install

npm install --save qdp2-oss

使用

method:

// 普通上传

put(initOptions, fileName, file, option)

// 分片上传(ali-oss)

multipartUpload(initOptions, fileName, file, option)

// 下载

// getPresigned(initOptions, fileName)

initOptions:

参数说明类型默认值
type选择sdk类型'aliyun' 'minio'string'aliyun'
region选择aliyun时必填,对应ali-ossregionstring--
endpoint必填,对应ali-ossendpoint,或 MinIOendPointstring--
bucket必填,对象存储的桶string--
tokenHost选择aliyun时必填,请求stsToken的接口地址string--
useSSLminio,是否开启SSL,本地调试设为falsebooleantrue
accessKeyminio时必填,账号string--
secretKeyminio时必填,密码string--

example:

// 标品
{
    "type": 'aliyun',
    "region": 'xxx',
    "endpoint": 'xxxxx.aliyuncs.com',
    "bucket": 'xxxxxxx',
    "tokenHost": 'http://xxxxx/xxxxx/xxxxx',
}
// ka
{
    "type": 'minio',
    "endpoint": 'xxx.xx.xx',
    "useSSL": false,
    "accessKey": 'xxxxxxx',
    "secretKey": 'xxxxxxxx',
    "bucket": 'xxxxxxx',
}

fileName: 上传文件名称,包含存放路径

file: 文件

option: 对应ali-oss 方法的option

完整example:

import * as qdp2OSS from "qdp2-oss";

const options = process.env.oss;
const fileName = `xxxx/${Date.now()}_${Math.trunc(Math.random() * 10000)}_${file.name}`;
qdp2OSS.put(options, fileName, file)
  .then((result) => {
    console.log(result);
  })
  .catch((err) => {
   });
0.1.23

2 years ago

0.1.24

2 years ago

0.1.20

2 years ago

0.1.21

2 years ago

0.1.22

2 years ago

0.1.13

2 years ago

0.1.14

2 years ago

0.1.15

2 years ago

0.1.16

2 years ago

0.1.18

2 years ago

0.1.19

2 years ago

0.1.12

4 years ago

0.1.10

4 years ago

0.1.11

4 years ago

0.1.9

4 years ago

0.1.8

4 years ago