@cloudbase/manager-node 4.7.1 → 4.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/function/index.js
CHANGED
|
@@ -1298,12 +1298,12 @@ class FunctionService {
|
|
|
1298
1298
|
}
|
|
1299
1299
|
async getCodeParams(options, installDependency) {
|
|
1300
1300
|
const { func, functionPath, functionRootPath, base64Code, deployMode } = options;
|
|
1301
|
-
//
|
|
1302
|
-
//
|
|
1303
|
-
const MAX_ZIP_SIZE =
|
|
1304
|
-
const MAX_BASE64_LENGTH = Math.floor(MAX_ZIP_SIZE * 4 / 3); // ≈
|
|
1301
|
+
// 直接传入 base64Code 的情况,校验大小
|
|
1302
|
+
// ZipFile 上传大小上限 1.5MB,base64 编码后长度约为原始大小的 4/3
|
|
1303
|
+
const MAX_ZIP_SIZE = 1.5 * 1024 * 1024; // 1.5MB
|
|
1304
|
+
const MAX_BASE64_LENGTH = Math.floor(MAX_ZIP_SIZE * 4 / 3); // ≈ 2097152
|
|
1305
1305
|
if ((base64Code === null || base64Code === void 0 ? void 0 : base64Code.length) > MAX_BASE64_LENGTH) {
|
|
1306
|
-
throw new error_1.CloudBaseError('
|
|
1306
|
+
throw new error_1.CloudBaseError('ZipFile 上传不能大于 1.5MB,请使用 COS 上传方式');
|
|
1307
1307
|
}
|
|
1308
1308
|
if (base64Code === null || base64Code === void 0 ? void 0 : base64Code.length) {
|
|
1309
1309
|
return {
|
|
@@ -1323,10 +1323,14 @@ class FunctionService {
|
|
|
1323
1323
|
root: functionRootPath
|
|
1324
1324
|
});
|
|
1325
1325
|
await packer.build();
|
|
1326
|
-
//
|
|
1327
|
-
// 判断是否需要走 COS 上传
|
|
1326
|
+
// 判断是否超过 ZipFile 上传大小限制(1.5MB)
|
|
1328
1327
|
const reachMax = await packer.isReachMaxSize();
|
|
1329
|
-
|
|
1328
|
+
// 如果指定了 zip 上传方式但超过大小限制,直接报错
|
|
1329
|
+
if (deployMode === 'zip' && reachMax) {
|
|
1330
|
+
throw new error_1.CloudBaseError('ZipFile 上传不能大于 1.5MB,请使用 COS 上传方式(deployMode: "cos")');
|
|
1331
|
+
}
|
|
1332
|
+
// 走 COS 上传:指定 cos 模式,或未指定模式但超过大小限制
|
|
1333
|
+
const useCos = deployMode === 'cos' || reachMax;
|
|
1330
1334
|
if (useCos) {
|
|
1331
1335
|
// 先调用scf的 COS 上传方式
|
|
1332
1336
|
const legacyResult = await this.uploadFunctionZipToCosLegacy(options, installDependency);
|
package/lib/function/packer.js
CHANGED
|
@@ -47,7 +47,8 @@ const error_1 = require("../error");
|
|
|
47
47
|
const os = __importStar(require("os"));
|
|
48
48
|
// 10 MB
|
|
49
49
|
exports.BIG_FILE_SIZE = 10485760;
|
|
50
|
-
|
|
50
|
+
// ZipFile 上传最大 1.5MB
|
|
51
|
+
exports.API_MAX_SIZE = 1.5 * 1024 * 1024;
|
|
51
52
|
var CodeType;
|
|
52
53
|
(function (CodeType) {
|
|
53
54
|
CodeType[CodeType["File"] = 0] = "File";
|
|
@@ -136,7 +137,7 @@ class FunctionPacker {
|
|
|
136
137
|
const fileStats = await promiseStat(this.zipFilePath);
|
|
137
138
|
return fileStats.size > exports.BIG_FILE_SIZE;
|
|
138
139
|
}
|
|
139
|
-
//
|
|
140
|
+
// ZipFile 上传最大 1.5MB
|
|
140
141
|
async isReachMaxSize() {
|
|
141
142
|
if (!this.zipFilePath) {
|
|
142
143
|
await this.build();
|
package/package.json
CHANGED