diff options
| author | Konstantin Lebedev <9497591+kmlebedev@users.noreply.github.com> | 2022-11-04 21:10:33 +0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-04 09:10:33 -0700 |
| commit | 5431c445cd820d685ff06bdb9a2aa400f2c61a46 (patch) | |
| tree | b0bace5539e9a09543653cbc056a8eace379eb2c | |
| parent | 167077fae009d9092cff28c43060dd93998cd228 (diff) | |
| download | seaweedfs-5431c445cd820d685ff06bdb9a2aa400f2c61a46.tar.xz seaweedfs-5431c445cd820d685ff06bdb9a2aa400f2c61a46.zip | |
fix filer.remote.sync to azure with ContentType (#3949)
* fix filer.remote.sync to azure with ContentType
* fix pass X-Amz-Meta to X-Ms-Meta
| -rw-r--r-- | weed/remote_storage/azure/azure_storage_client.go | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/weed/remote_storage/azure/azure_storage_client.go b/weed/remote_storage/azure/azure_storage_client.go index ad2bbdacb..af67c8565 100644 --- a/weed/remote_storage/azure/azure_storage_client.go +++ b/weed/remote_storage/azure/azure_storage_client.go @@ -3,6 +3,7 @@ package azure import ( "context" "fmt" + "github.com/seaweedfs/seaweedfs/weed/s3api/s3_constants" "io" "net/url" "os" @@ -146,23 +147,17 @@ func (az *azureRemoteStorageClient) WriteFile(loc *remote_pb.RemoteStorageLocati fileSize := int64(filer.FileSize(entry)) _, err = uploadReaderAtToBlockBlob(context.Background(), readerAt, fileSize, blobURL, azblob.UploadToBlockBlobOptions{ - BlockSize: 4 * 1024 * 1024, - Parallelism: 16}) + BlockSize: 4 * 1024 * 1024, + BlobHTTPHeaders: azblob.BlobHTTPHeaders{ContentType: entry.Attributes.Mime}, + Metadata: toMetadata(entry.Extended), + Parallelism: 16, + }) if err != nil { return nil, fmt.Errorf("azure upload to %s%s: %v", loc.Bucket, loc.Path, err) } - metadata := toMetadata(entry.Extended) - if len(metadata) > 0 { - _, err = blobURL.SetMetadata(context.Background(), metadata, azblob.BlobAccessConditions{}, azblob.ClientProvidedKeyOptions{}) - if err != nil { - return nil, fmt.Errorf("azure set metadata on %s%s: %v", loc.Bucket, loc.Path, err) - } - } - // read back the remote entry return az.readFileRemoteEntry(loc) - } func (az *azureRemoteStorageClient) readFileRemoteEntry(loc *remote_pb.RemoteStorageLocation) (*filer_pb.RemoteEntry, error) { @@ -188,10 +183,9 @@ func (az *azureRemoteStorageClient) readFileRemoteEntry(loc *remote_pb.RemoteSto func toMetadata(attributes map[string][]byte) map[string]string { metadata := make(map[string]string) for k, v := range attributes { - if strings.HasPrefix(k, "X-") { - continue + if strings.HasPrefix(k, s3_constants.AmzUserMetaPrefix) { + metadata[k[len(s3_constants.AmzUserMetaPrefix):]] = string(v) } - metadata[k] = string(v) } return metadata } |
