|
|
@ -3,7 +3,6 @@ package weed_server |
|
|
import ( |
|
|
import ( |
|
|
"bytes" |
|
|
"bytes" |
|
|
"context" |
|
|
"context" |
|
|
"encoding/base64" |
|
|
|
|
|
"errors" |
|
|
"errors" |
|
|
"fmt" |
|
|
"fmt" |
|
|
"io" |
|
|
"io" |
|
|
@ -174,10 +173,6 @@ func skipCheckParentDirEntry(r *http.Request) bool { |
|
|
return r.URL.Query().Get("skipCheckParentDir") == "true" |
|
|
return r.URL.Query().Get("skipCheckParentDir") == "true" |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func isS3Request(r *http.Request) bool { |
|
|
|
|
|
return r.Header.Get(s3_constants.AmzAuthType) != "" || r.Header.Get("X-Amz-Date") != "" |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (fs *FilerServer) checkPermissions(ctx context.Context, r *http.Request, fileName string) error { |
|
|
func (fs *FilerServer) checkPermissions(ctx context.Context, r *http.Request, fileName string) error { |
|
|
fullPath := fs.fixFilePath(ctx, r, fileName) |
|
|
fullPath := fs.fixFilePath(ctx, r, fileName) |
|
|
enforced, err := fs.wormEnforcedForEntry(ctx, fullPath) |
|
|
enforced, err := fs.wormEnforcedForEntry(ctx, fullPath) |
|
|
@ -357,52 +352,7 @@ func (fs *FilerServer) saveMetaData(ctx context.Context, r *http.Request, fileNa |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Process SSE metadata headers sent by S3 API and store in entry extended metadata
|
|
|
|
|
|
if sseIVHeader := r.Header.Get(s3_constants.SeaweedFSSSEIVHeader); sseIVHeader != "" { |
|
|
|
|
|
// Decode base64-encoded IV and store in metadata
|
|
|
|
|
|
if ivData, err := base64.StdEncoding.DecodeString(sseIVHeader); err == nil { |
|
|
|
|
|
entry.Extended[s3_constants.SeaweedFSSSEIV] = ivData |
|
|
|
|
|
glog.V(4).Infof("Stored SSE-C IV metadata for %s", entry.FullPath) |
|
|
|
|
|
} else { |
|
|
|
|
|
glog.Errorf("Failed to decode SSE-C IV header for %s: %v", entry.FullPath, err) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Store SSE-C algorithm and key MD5 for proper S3 API response headers
|
|
|
|
|
|
if sseAlgorithm := r.Header.Get(s3_constants.AmzServerSideEncryptionCustomerAlgorithm); sseAlgorithm != "" { |
|
|
|
|
|
entry.Extended[s3_constants.AmzServerSideEncryptionCustomerAlgorithm] = []byte(sseAlgorithm) |
|
|
|
|
|
glog.V(4).Infof("Stored SSE-C algorithm metadata for %s", entry.FullPath) |
|
|
|
|
|
} |
|
|
|
|
|
if sseKeyMD5 := r.Header.Get(s3_constants.AmzServerSideEncryptionCustomerKeyMD5); sseKeyMD5 != "" { |
|
|
|
|
|
entry.Extended[s3_constants.AmzServerSideEncryptionCustomerKeyMD5] = []byte(sseKeyMD5) |
|
|
|
|
|
glog.V(4).Infof("Stored SSE-C key MD5 metadata for %s", entry.FullPath) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if sseKMSHeader := r.Header.Get(s3_constants.SeaweedFSSSEKMSKeyHeader); sseKMSHeader != "" { |
|
|
|
|
|
// Decode base64-encoded KMS metadata and store
|
|
|
|
|
|
if kmsData, err := base64.StdEncoding.DecodeString(sseKMSHeader); err == nil { |
|
|
|
|
|
entry.Extended[s3_constants.SeaweedFSSSEKMSKey] = kmsData |
|
|
|
|
|
glog.V(4).Infof("Stored SSE-KMS metadata for %s", entry.FullPath) |
|
|
|
|
|
} else { |
|
|
|
|
|
glog.Errorf("Failed to decode SSE-KMS metadata header for %s: %v", entry.FullPath, err) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if sseS3Header := r.Header.Get(s3_constants.SeaweedFSSSES3Key); sseS3Header != "" { |
|
|
|
|
|
// Decode base64-encoded S3 metadata and store
|
|
|
|
|
|
if s3Data, err := base64.StdEncoding.DecodeString(sseS3Header); err == nil { |
|
|
|
|
|
entry.Extended[s3_constants.SeaweedFSSSES3Key] = s3Data |
|
|
|
|
|
glog.V(4).Infof("Stored SSE-S3 metadata for %s", entry.FullPath) |
|
|
|
|
|
} else { |
|
|
|
|
|
glog.Errorf("Failed to decode SSE-S3 metadata header for %s: %v", entry.FullPath, err) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
dbErr := fs.filer.CreateEntry(ctx, entry, false, false, nil, skipCheckParentDirEntry(r), so.MaxFileNameLength) |
|
|
dbErr := fs.filer.CreateEntry(ctx, entry, false, false, nil, skipCheckParentDirEntry(r), so.MaxFileNameLength) |
|
|
// In test_bucket_listv2_delimiter_basic, the valid object key is the parent folder
|
|
|
|
|
|
if dbErr != nil && strings.HasSuffix(dbErr.Error(), " is a file") && isS3Request(r) { |
|
|
|
|
|
dbErr = fs.filer.CreateEntry(ctx, entry, false, false, nil, true, so.MaxFileNameLength) |
|
|
|
|
|
} |
|
|
|
|
|
if dbErr != nil { |
|
|
if dbErr != nil { |
|
|
replyerr = dbErr |
|
|
replyerr = dbErr |
|
|
filerResult.Error = dbErr.Error() |
|
|
filerResult.Error = dbErr.Error() |
|
|
|