fix(s3): incorrectly added slash before the Bucket name #8083
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
背景
该Bug主要涉及到Issue #8001,Error可复现,表现为S3存储无法重命名文件
复现环境
后端使用Master分支,Commit 370a6c1,启动后进行一次重命名,在页面上会报错

同时查看日志有:
解决方案
跟进实际执行的逻辑,使用了s3 client的CopyObject接口,逻辑实现位于
drivers/s3/util.go
的copyFile函数:问题在于CopySource的参数值不应该在Bucket前面再添加斜杠,参考官方文档https://docs.aws.amazon.com/code-library/latest/ug/go_2_s3_code_examples.html同样没有在前面添加斜杠,而是
aws.String(fmt.Sprintf("%v/%v", sourceBucket, objectKey))
,对该行修改后重新启动后端,问题解决,并且在R2中验证正确: