cdn-transfer
TypeScript icon, indicating that this package has built-in type declarations

0.0.6-beta.1 • Public • Published

解决问题

作为阿里云oss/腾讯云 cos 项目文件上传入口;

使用场景:

  1. 前端打包dist文件上传, 并使用package中name,version字段作为prefix名
  2. 文件夹下文件批量上传;

使用示例

import Transfer from  'cdn-transfer';

//默认前缀: {name}/{version}/
cdnTransfer.default(path.join(__dirname, '..'), {
  SecretId: '********',
  SecretKey: '********',
  Bucket: 'fr********22416',
  Region: 'ap-shanghai'
});

//自定义上传目录: 
cdnTransfer.default(path.join(__dirname, '..'), {
  SecretId: '********',
  SecretKey: '********',
  Bucket: 'fr********22416',
  Region: 'ap-shanghai',
  sourceDir:"./dist",
  prefix:(fileRelPath)=>{
    return `test/${fileRelPath}`
  }
});



//自定义前缀: 
cdnTransfer.default(path.join(__dirname, '..'), {
  SecretId: '********',
  SecretKey: '********',
  Bucket: 'fr********22416',
  Region: 'ap-shanghai',
  prefix:(fileRelPath)=>{
    return `test/${fileRelPath}`
  }
});

//上传单个文件; 


import {uploadFile} from  'cdn-transfer';

let vistiUrl =await uploadFile({
  fileAbsPath:"",
  ossVisitPath:"",
  config:{
    cdn:"cos",
    SecretId: '********',
    SecretKey: '********',
    Bucket: 'fr********22416',
    Region: 'ap-shanghai',
  }
});



Readme

Keywords

none

Package Sidebar

Install

npm i cdn-transfer

Weekly Downloads

13

Version

0.0.6-beta.1

License

MIT

Unpacked Size

17.1 kB

Total Files

22

Last publish

Collaborators

  • yangxiaodong