@kevisual/oss 0.0.19 → 0.0.20

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kevisual/oss",
3
- "version": "0.0.19",
3
+ "version": "0.0.20",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "build": "bun run bun.config.ts"
@@ -27,9 +27,10 @@ export const copyObject = async ({ bucketName, newMetadata, objectName, client }
27
27
  const { standardHeaders, customMetadata } = extractStandardHeaders(mergedMeta);
28
28
 
29
29
  // 执行复制操作(同一对象,用于更新元数据)
30
+ // 注意:CopySource 中的 key 必须进行 URL 编码,否则包含特殊字符时会报错
30
31
  const copyCommand = new CopyObjectCommand({
31
32
  Bucket: bucketName,
32
- CopySource: `${bucketName}/${objectName}`,
33
+ CopySource: `${bucketName}/${encodeURIComponent(objectName)}`,
33
34
  Key: objectName,
34
35
  ContentType: standardHeaders.ContentType,
35
36
  CacheControl: standardHeaders.CacheControl,
package/src/s3/core.ts CHANGED
@@ -420,7 +420,7 @@ export class OssBase implements OssBaseOperation {
420
420
  async copyObject(sourceObject: string, targetObject: string): Promise<any> {
421
421
  const command = new CopyObjectCommand({
422
422
  Bucket: this.bucketName,
423
- CopySource: `${this.bucketName}/${this.prefix}${sourceObject}`,
423
+ CopySource: `${this.bucketName}/${encodeURIComponent(this.prefix + sourceObject)}`,
424
424
  Key: `${this.prefix}${targetObject}`,
425
425
  });
426
426
  const response = await this.client.send(command);
@@ -443,7 +443,7 @@ export class OssBase implements OssBaseOperation {
443
443
 
444
444
  const command = new CopyObjectCommand({
445
445
  Bucket: this.bucketName,
446
- CopySource: `${this.bucketName}/${key}`,
446
+ CopySource: `${this.bucketName}/${encodeURIComponent(key)}`,
447
447
  Key: key,
448
448
  ContentType: standardHeaders.ContentType,
449
449
  CacheControl: standardHeaders.CacheControl,