Skip to content
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

fix: the same-storage check in the new pre-sign feature #2860

Merged
merged 4 commits into from
Jan 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions plugin/storage/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (client *Client) UploadFile(ctx context.Context, filename string, fileType
ContentType: aws.String(fileType),
}
// Set ACL according to if url prefix is set.
if client.Config.URLPrefix == "" {
if client.Config.URLPrefix == "" && !client.Config.PreSign {
putInput.ACL = types.ObjectCannedACL(*aws.String("public-read"))
}
uploadOutput, err := uploader.Upload(ctx, &putInput)
Expand Down Expand Up @@ -113,7 +113,15 @@ func (client *Client) PreSignLink(ctx context.Context, sourceLink string) (strin
}
// if link doesn't belong to storage, then return as-is.
// the empty hostname is corner-case for AWS native endpoint.
if client.Config.EndPoint != "" && !strings.Contains(client.Config.EndPoint, u.Hostname()) {
endpointURL, err := url.Parse(client.Config.EndPoint)
if err != nil {
return "", errors.Wrapf(err, "parse Endpoint URL")
}
endpointHost := endpointURL.Hostname()
if client.Config.Bucket != "" && !strings.Contains(endpointHost, client.Config.Bucket) {
endpointHost = fmt.Sprintf("%s.%s", client.Config.Bucket, endpointHost)
}
if client.Config.EndPoint != "" && !strings.Contains(endpointHost, u.Hostname()) {
return sourceLink, nil
}

Expand Down