|
@@ -8,7 +8,7 @@ const { execSync } = require("child_process");
|
|
class saveOssGitte {
|
|
class saveOssGitte {
|
|
constructor() {
|
|
constructor() {
|
|
this.localDir = "dist/";
|
|
this.localDir = "dist/";
|
|
- this.baseOssDir = "topic/activity/";
|
|
|
|
|
|
+ this.baseOssDir = "operate/products/";
|
|
this.client = new oss({
|
|
this.client = new oss({
|
|
region: "oss-cn-chengdu",
|
|
region: "oss-cn-chengdu",
|
|
// 阿里云账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM用户进行API访问或日常运维,请登录RAM控制台创建RAM用户。
|
|
// 阿里云账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM用户进行API访问或日常运维,请登录RAM控制台创建RAM用户。
|
|
@@ -58,9 +58,11 @@ class saveOssGitte {
|
|
);
|
|
);
|
|
console.log("oss文件清除---完成");
|
|
console.log("oss文件清除---完成");
|
|
try {
|
|
try {
|
|
|
|
+ console.log(path.resolve(__dirname, "./" + this.localDir))
|
|
await this.getFiles(path.resolve(__dirname, "./" + this.localDir));
|
|
await this.getFiles(path.resolve(__dirname, "./" + this.localDir));
|
|
console.log("数据上传oss---完成");
|
|
console.log("数据上传oss---完成");
|
|
} catch (err) {
|
|
} catch (err) {
|
|
|
|
+ console.log(err)
|
|
console.log("数据上传oss---失败");
|
|
console.log("数据上传oss---失败");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -72,10 +74,11 @@ class saveOssGitte {
|
|
const dirList = fs.readdirSync(pathDir) || [];
|
|
const dirList = fs.readdirSync(pathDir) || [];
|
|
for (let i = 0; i < dirList.length; i++) {
|
|
for (let i = 0; i < dirList.length; i++) {
|
|
const P = [pathDir, dirList[i]];
|
|
const P = [pathDir, dirList[i]];
|
|
- const stat = fs.lstatSync(P.join("\\"));
|
|
|
|
|
|
+ const stat = fs.lstatSync(P.join("/"));
|
|
if (!stat.isDirectory()) {
|
|
if (!stat.isDirectory()) {
|
|
|
|
+ console.log(P)
|
|
await this.upFileOSS(P);
|
|
await this.upFileOSS(P);
|
|
- } else this.getFiles(P.join("\\"));
|
|
|
|
|
|
+ } else this.getFiles(P.join("/"));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -87,12 +90,12 @@ class saveOssGitte {
|
|
try {
|
|
try {
|
|
// 填写OSS文件完整路径和本地文件的完整路径。OSS文件完整路径中不能包含Bucket名称。
|
|
// 填写OSS文件完整路径和本地文件的完整路径。OSS文件完整路径中不能包含Bucket名称。
|
|
// 如果本地文件的完整路径中未指定本地路径,则默认从示例程序所属项目对应本地路径中上传文件。
|
|
// 如果本地文件的完整路径中未指定本地路径,则默认从示例程序所属项目对应本地路径中上传文件。
|
|
- 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(
|
|
await this.client.put(
|
|
this.baseOssDir + dir + filePath[1],
|
|
this.baseOssDir + dir + filePath[1],
|
|
- path.normalize(filePath.join("\\"))
|
|
|
|
|
|
+ path.normalize(filePath.join("/"))
|
|
// 自定义headers
|
|
// 自定义headers
|
|
//,{headers}
|
|
//,{headers}
|
|
);
|
|
);
|