|
@@ -59,7 +59,6 @@ class saveOssGitte {
|
|
console.log("oss文件清除---完成");
|
|
console.log("oss文件清除---完成");
|
|
try {
|
|
try {
|
|
await this.getFiles(path.resolve(__dirname, "./" + this.localDir));
|
|
await this.getFiles(path.resolve(__dirname, "./" + this.localDir));
|
|
- console.log("数据上传oss---完成");
|
|
|
|
} catch (err) {
|
|
} catch (err) {
|
|
console.log("数据上传oss---失败");
|
|
console.log("数据上传oss---失败");
|
|
}
|
|
}
|
|
@@ -90,12 +89,19 @@ class saveOssGitte {
|
|
let dir = filePath[0].split("\\");
|
|
let dir = filePath[0].split("\\");
|
|
dir = dir.reverse()[0] + "/";
|
|
dir = dir.reverse()[0] + "/";
|
|
if (dir === this.localDir) dir = "";
|
|
if (dir === this.localDir) dir = "";
|
|
- await this.client.put(
|
|
|
|
- this.baseOssDir + dir + filePath[1],
|
|
|
|
- path.normalize(filePath.join("\\"))
|
|
|
|
- // 自定义headers
|
|
|
|
- //,{headers}
|
|
|
|
- );
|
|
|
|
|
|
+ // await this.client.put(
|
|
|
|
+ // this.baseOssDir + dir + filePath[1],
|
|
|
|
+ // path.normalize(filePath.join("\\"))
|
|
|
|
+ // // 自定义headers
|
|
|
|
+ // //,{headers}
|
|
|
|
+ // );
|
|
|
|
+
|
|
|
|
+ const result = await client.multipartUpload(filePath[1], this.baseOssDir + dir + filePath[1], {
|
|
|
|
+ partSize: 1 * 1024 * 1024, // 分片大小1MB
|
|
|
|
+ progress: (p) => console.log(`进度:${Math.round(p * 100)}%`)
|
|
|
|
+ });
|
|
|
|
+ console.log('分片上传完成:', result);
|
|
|
|
+ console.log("数据上传oss---完成");
|
|
} catch (e) {
|
|
} catch (e) {
|
|
console.error("未成功上传:", filePath.join("\\"));
|
|
console.error("未成功上传:", filePath.join("\\"));
|
|
console.log("err--->", e);
|
|
console.log("err--->", e);
|