New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

cdn-transfer

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cdn-transfer

process static file

latest
npmnpm
Version
0.0.6-beta.1
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

解决问题

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

使用场景:

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

使用示例


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',
  }
});





FAQs

Package last updated on 25 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts