fix: s3 custom path (#1249)

This commit is contained in:
boojack 2023-03-04 20:06:32 +08:00 committed by GitHub
parent e150599274
commit 31399fe475
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -67,11 +67,12 @@ func (client *Client) UploadFile(ctx context.Context, filename string, fileType
}
link := uploadOutput.Location
if link == "" {
if client.Config.URLPrefix == "" {
return "", fmt.Errorf("url prefix is empty")
}
// If url prefix is set, use it as the file link.
if client.Config.URLPrefix != "" {
link = fmt.Sprintf("%s/%s", client.Config.URLPrefix, filename)
}
if link == "" {
return "", fmt.Errorf("failed to get file link")
}
return link, nil
}