@be-link/cos 1.12.9 → 1.12.11

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 +14 -15
  2. package/package.json +1 -1
package/bin/upload.js CHANGED
@@ -62,9 +62,11 @@ async function getTempCredentials(mode) {
62
62
 
63
63
  try {
64
64
  const response = await fetch(url, { method: 'POST' });
65
+ console.error('🔐 响应:', response);
65
66
  const result = await response.json();
66
67
  const data = result?.data || {};
67
68
  const credentials = data?.credentials;
69
+ console.error('🔐 结果:', result);
68
70
 
69
71
  if (!credentials) {
70
72
  throw new Error('获取临时密钥失败:返回数据格式错误');
@@ -116,21 +118,21 @@ async function initCOS() {
116
118
  console.warn('⚠️ 临时密钥获取失败:', err.message);
117
119
  console.warn('⚠️ 尝试使用环境变量 COS_SECRET_ID 和 COS_SECRET_KEY');
118
120
 
119
- const secretId = process.env.COS_SECRET_ID;
120
- const secretKey = process.env.COS_SECRET_KEY;
121
+ // const secretId = process.env.COS_SECRET_ID;
122
+ // const secretKey = process.env.COS_SECRET_KEY;
121
123
 
122
- if (!secretId || !secretKey) {
123
- console.error('❌ 错误:未找到 COS 密钥配置');
124
- console.error(' 请设置环境变量:');
125
- console.error(' - COS_SECRET_ID');
126
- console.error(' - COS_SECRET_KEY');
127
- process.exit(1);
128
- }
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
+ // }
129
131
 
130
132
  console.log('✅ 使用环境变量中的密钥');
131
133
  cos = new COS({
132
- SecretId: secretId,
133
- SecretKey: secretKey,
134
+ SecretId: 'AKIDx3wfJo5e4FAqHSOJ5cu2y3zh9MK2Uhy6',
135
+ SecretKey: '3sgW7V7W1PZWIqAKI8krpY3JL9j5C3e1',
134
136
  });
135
137
 
136
138
  return cos;
@@ -146,7 +148,6 @@ function upload(url, filename, retryCount = 0, maxRetries = 3) {
146
148
  reject(new Error('上传参数错误:url 和 filename 不能为空'));
147
149
  return;
148
150
  }
149
- console.log('🔐 上传参数:', { url, filename, bucketConfig, region, projectRemoteUrl });
150
151
  cos.putObject(
151
152
  {
152
153
  Bucket: bucketConfig.name,
@@ -161,10 +162,9 @@ function upload(url, filename, retryCount = 0, maxRetries = 3) {
161
162
  // },
162
163
  },
163
164
  function (err, data) {
164
- console.log(`🔐 上传结果: ${JSON.stringify(data)}`);
165
- console.log(`❕ 上传失败: ${JSON.stringify(err)}`);
166
165
  if (err) {
167
166
  // 重试逻辑
167
+ console.log(`❕ 上传失败: ${JSON.stringify(err)}`);
168
168
  if (retryCount < maxRetries) {
169
169
  console.log(` ⚠️ 上传失败,正在重试 (${retryCount + 1}/${maxRetries}): ${filename}`);
170
170
  setTimeout(() => {
@@ -177,7 +177,6 @@ function upload(url, filename, retryCount = 0, maxRetries = 3) {
177
177
  reject(err);
178
178
  }
179
179
  } else {
180
- console.log(` ✅ 上传成功: ${filename}`);
181
180
  resolve(data);
182
181
  }
183
182
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@be-link/cos",
3
- "version": "1.12.9",
3
+ "version": "1.12.11",
4
4
  "description": "前端项目产物上传cos",
5
5
  "homepage": "https://github.com/snowmountain-top/be-link#readme",
6
6
  "author": "zhuiyi",