Skip to content

Add Kingsoft Cloud object storage policy to solve the cross-domain and friendly file name incompatibility problem of s3 compatible storage policy. #2665

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 21, 2025

Conversation

omiku
Copy link
Contributor

@omiku omiku commented Jul 15, 2025

Closes #2642

@CLAassistant
Copy link

CLAassistant commented Jul 15, 2025

CLA assistant check
All committers have signed the CLA.

@HFO4
Copy link
Member

HFO4 commented Jul 15, 2025

Thanks a lot! Will take a look in a few days.

@Luncode
Copy link

Luncode commented Jul 15, 2025

Thanks a lot! Will take a look in a few days.

association frontend Pr: cloudreve/frontend#285

var contentDescription *string
if args.IsDownload {
encodedFilename := url.PathEscape(args.DisplayName)
contentDescription = aws.String(fmt.Sprintf(`attachment; filename="%s"`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we need to remove the punctuation mark:

contentDescription = aws.String(fmt.Sprintf(`attachment; filename=%s`, encodedFilename))

HTTPMethod: s3.GET, // 请求方法
Bucket: &handler.policy.BucketName, // 存储空间名称
Key: aws.String(e.Source()), // 对象的key
Expires: 604800, // 过期时间,7 days
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not follow args.Expire?

ContentType: aws.String("application/octet-stream"),
})
if err != nil {
return fmt.Errorf("生成分片%d预签名URL失败: %w", partNumber, err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return fmt.Errorf("failed to generate presigned upload url for chunk %d: %w", partNumber, err)

@omiku
Copy link
Contributor Author

omiku commented Jul 20, 2025

Codes have been corrected as required

HTTPMethod: s3.GET, // 请求方法
Bucket: &handler.policy.BucketName, // 存储空间名称
Key: aws.String(e.Source()), // 对象的key
Expires: int64(time.Until(*args.Expire).Seconds()), // 过期时间,转换为秒数
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please refer to https://github.com/cloudreve/cloudreve/blob/1cdccf5fc95aa7be432666e7f93ae95e02b61297/pkg/filemanager/driver/s3/s3.go#L309C2-L312C3

args.Expire might be nil, in which case default max TTL wil be used (7 days)

@omiku omiku requested a review from HFO4 July 21, 2025 06:15
@HFO4 HFO4 merged commit 488f325 into cloudreve:master Jul 21, 2025
2 checks passed
@HFO4
Copy link
Member

HFO4 commented Jul 21, 2025

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

金山云对象存储兼容问题
4 participants