提交 d7ba3173 authored 作者: lihuihui's avatar lihuihui

修改阿里云提交

上级 6641dfc7
......@@ -12,6 +12,10 @@ const client = new OSS({
bucket: 'zws-imgs-pub'
})
const headers = {
'x-oss-traffic-limit': 8 * 1024 * 100 * 100 // 设置限速,最小100KB/s。设置为 10000KB/s
}
const DIR_PATH = path.join(__dirname, '../' + conf.DesDir)
const PREFIX_PATH = conf.CDN_DIR
const isUploadStatic = conf.isUploadStatic
......@@ -20,7 +24,11 @@ let fileCount = 1
async function uploadFile(prefixPath, dirFileName) {
const upFilePath = prefixPath.replace(new RegExp(DIR_PATH, 'gi'), '') + path.basename(dirFileName)
try {
const result = await client.put(prefixPath + path.basename(dirFileName), dirFileName)
// const result = await client.put(prefixPath + path.basename(dirFileName), dirFileName)
let result = await client.put(prefixPath + path.basename(dirFileName), dirFileName, {
headers,
timeout: 600000 // 默认超时时长为60000ms。超时直接报错,限速上传时注意修改超时时长。设置为600s
})
if (result.res.status === 200) {
console.log('第' + fileCount++ + '个文件,已上传:' + conf.CDN_BASE + upFilePath)
return { status: 200 }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论