@be-link/cos 1.12.10 → 1.12.12

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.
Files changed (2) hide show
  1. package/bin/upload.js +13 -16
  2. package/package.json +1 -1
package/bin/upload.js CHANGED
@@ -118,21 +118,21 @@ async function initCOS() {
118
118
  console.warn('⚠️ 临时密钥获取失败:', err.message);
119
119
  console.warn('⚠️ 尝试使用环境变量 COS_SECRET_ID 和 COS_SECRET_KEY');
120
120
 
121
- // const secretId = process.env.COS_SECRET_ID;
122
- // const secretKey = process.env.COS_SECRET_KEY;
123
-
124
- // if (!secretId || !secretKey) {
125
- // console.error('❌ 错误:未找到 COS 密钥配置');
126
- // console.error(' 请设置环境变量:');
127
- // console.error(' - COS_SECRET_ID');
128
- // console.error(' - COS_SECRET_KEY');
129
- // process.exit(1);
130
- // }
121
+ const secretId = process.env.COS_SECRET_ID;
122
+ const secretKey = process.env.COS_SECRET_KEY;
123
+
124
+ if (!secretId || !secretKey) {
125
+ console.error('❌ 错误:未找到 COS 密钥配置');
126
+ console.error(' 请设置环境变量:');
127
+ console.error(' - COS_SECRET_ID');
128
+ console.error(' - COS_SECRET_KEY');
129
+ process.exit(1);
130
+ }
131
131
 
132
132
  console.log('✅ 使用环境变量中的密钥');
133
133
  cos = new COS({
134
- SecretId: 'AKIDx3wfJo5e4FAqHSOJ5cu2y3zh9MK2Uhy6',
135
- SecretKey: '3sgW7V7W1PZWIqAKI8krpY3JL9j5C3e1',
134
+ SecretId: secretId,
135
+ SecretKey: secretKey,
136
136
  });
137
137
 
138
138
  return cos;
@@ -148,7 +148,6 @@ function upload(url, filename, retryCount = 0, maxRetries = 3) {
148
148
  reject(new Error('上传参数错误:url 和 filename 不能为空'));
149
149
  return;
150
150
  }
151
- console.log('🔐 上传参数:', { url, filename, bucketConfig, region, projectRemoteUrl });
152
151
  cos.putObject(
153
152
  {
154
153
  Bucket: bucketConfig.name,
@@ -163,10 +162,9 @@ function upload(url, filename, retryCount = 0, maxRetries = 3) {
163
162
  // },
164
163
  },
165
164
  function (err, data) {
166
- console.log(`🔐 上传结果: ${JSON.stringify(data)}`);
167
- console.log(`❕ 上传失败: ${JSON.stringify(err)}`);
168
165
  if (err) {
169
166
  // 重试逻辑
167
+ console.log(`❕ 上传失败: ${JSON.stringify(err)}`);
170
168
  if (retryCount < maxRetries) {
171
169
  console.log(` ⚠️ 上传失败,正在重试 (${retryCount + 1}/${maxRetries}): ${filename}`);
172
170
  setTimeout(() => {
@@ -179,7 +177,6 @@ function upload(url, filename, retryCount = 0, maxRetries = 3) {
179
177
  reject(err);
180
178
  }
181
179
  } else {
182
- console.log(` ✅ 上传成功: ${filename}`);
183
180
  resolve(data);
184
181
  }
185
182
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@be-link/cos",
3
- "version": "1.12.10",
3
+ "version": "1.12.12",
4
4
  "description": "前端项目产物上传cos",
5
5
  "homepage": "https://github.com/snowmountain-top/be-link#readme",
6
6
  "author": "zhuiyi",