Browse Source

Use S3 endpoint in multipart Location instead of filer address

pull/7550/head
Chris Lu 3 days ago
parent
commit
ebad1f6fbd
  1. 13
      weed/s3api/filer_multipart.go

13
weed/s3api/filer_multipart.go

@ -183,11 +183,10 @@ func (s3a *S3ApiServer) completeMultipartUpload(r *http.Request, input *s3.Compl
entryName, dirName := s3a.getEntryNameAndDir(input) entryName, dirName := s3a.getEntryNameAndDir(input)
if entry, _ := s3a.getEntry(dirName, entryName); entry != nil && entry.Extended != nil { if entry, _ := s3a.getEntry(dirName, entryName); entry != nil && entry.Extended != nil {
if uploadId, ok := entry.Extended[s3_constants.SeaweedFSUploadId]; ok && *input.UploadId == string(uploadId) { if uploadId, ok := entry.Extended[s3_constants.SeaweedFSUploadId]; ok && *input.UploadId == string(uploadId) {
// Note: Location URL is informational per AWS S3 API spec
// Clients should use the S3 API endpoint, not this direct URL
// Points to current active filer (not a concern since it's not used for actual access)
// Location uses the S3 endpoint that the client connected to
// Format: http://s3-endpoint/bucket/object (following AWS S3 API)
return &CompleteMultipartUploadResult{ return &CompleteMultipartUploadResult{
Location: aws.String(fmt.Sprintf("http://%s%s/%s", s3a.getFilerAddress().ToHttpAddress(), urlEscapeObject(dirName), urlPathEscape(entryName))),
Location: aws.String(fmt.Sprintf("http://%s/%s%s", r.Host, *input.Bucket, *input.Key)),
Bucket: input.Bucket, Bucket: input.Bucket,
ETag: aws.String("\"" + filer.ETagChunks(entry.GetChunks()) + "\""), ETag: aws.String("\"" + filer.ETagChunks(entry.GetChunks()) + "\""),
Key: objectKey(input.Key), Key: objectKey(input.Key),
@ -404,7 +403,7 @@ func (s3a *S3ApiServer) completeMultipartUpload(r *http.Request, input *s3.Compl
// The latest version information is tracked in the .versions directory metadata // The latest version information is tracked in the .versions directory metadata
output = &CompleteMultipartUploadResult{ output = &CompleteMultipartUploadResult{
Location: aws.String(fmt.Sprintf("http://%s%s/%s", s3a.getFilerAddress().ToHttpAddress(), urlEscapeObject(dirName), urlPathEscape(entryName))),
Location: aws.String(fmt.Sprintf("http://%s/%s%s", r.Host, *input.Bucket, *input.Key)),
Bucket: input.Bucket, Bucket: input.Bucket,
ETag: aws.String("\"" + filer.ETagChunks(finalParts) + "\""), ETag: aws.String("\"" + filer.ETagChunks(finalParts) + "\""),
Key: objectKey(input.Key), Key: objectKey(input.Key),
@ -457,7 +456,7 @@ func (s3a *S3ApiServer) completeMultipartUpload(r *http.Request, input *s3.Compl
// Note: Suspended versioning should NOT return VersionId field according to AWS S3 spec // Note: Suspended versioning should NOT return VersionId field according to AWS S3 spec
output = &CompleteMultipartUploadResult{ output = &CompleteMultipartUploadResult{
Location: aws.String(fmt.Sprintf("http://%s%s/%s", s3a.getFilerAddress().ToHttpAddress(), urlEscapeObject(dirName), urlPathEscape(entryName))),
Location: aws.String(fmt.Sprintf("http://%s/%s%s", r.Host, *input.Bucket, *input.Key)),
Bucket: input.Bucket, Bucket: input.Bucket,
ETag: aws.String("\"" + filer.ETagChunks(finalParts) + "\""), ETag: aws.String("\"" + filer.ETagChunks(finalParts) + "\""),
Key: objectKey(input.Key), Key: objectKey(input.Key),
@ -514,7 +513,7 @@ func (s3a *S3ApiServer) completeMultipartUpload(r *http.Request, input *s3.Compl
// For non-versioned buckets, return response without VersionId // For non-versioned buckets, return response without VersionId
output = &CompleteMultipartUploadResult{ output = &CompleteMultipartUploadResult{
Location: aws.String(fmt.Sprintf("http://%s%s/%s", s3a.getFilerAddress().ToHttpAddress(), urlEscapeObject(dirName), urlPathEscape(entryName))),
Location: aws.String(fmt.Sprintf("http://%s/%s%s", r.Host, *input.Bucket, *input.Key)),
Bucket: input.Bucket, Bucket: input.Bucket,
ETag: aws.String("\"" + filer.ETagChunks(finalParts) + "\""), ETag: aws.String("\"" + filer.ETagChunks(finalParts) + "\""),
Key: objectKey(input.Key), Key: objectKey(input.Key),

Loading…
Cancel
Save