mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
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
This commit is contained in:
parent
167077fae0
commit
5431c445cd
|
@ -3,6 +3,7 @@ package azure
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/seaweedfs/seaweedfs/weed/s3api/s3_constants"
|
||||||
"io"
|
"io"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
|
@ -147,22 +148,16 @@ func (az *azureRemoteStorageClient) WriteFile(loc *remote_pb.RemoteStorageLocati
|
||||||
|
|
||||||
_, err = uploadReaderAtToBlockBlob(context.Background(), readerAt, fileSize, blobURL, azblob.UploadToBlockBlobOptions{
|
_, err = uploadReaderAtToBlockBlob(context.Background(), readerAt, fileSize, blobURL, azblob.UploadToBlockBlobOptions{
|
||||||
BlockSize: 4 * 1024 * 1024,
|
BlockSize: 4 * 1024 * 1024,
|
||||||
Parallelism: 16})
|
BlobHTTPHeaders: azblob.BlobHTTPHeaders{ContentType: entry.Attributes.Mime},
|
||||||
|
Metadata: toMetadata(entry.Extended),
|
||||||
|
Parallelism: 16,
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("azure upload to %s%s: %v", loc.Bucket, loc.Path, err)
|
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
|
// read back the remote entry
|
||||||
return az.readFileRemoteEntry(loc)
|
return az.readFileRemoteEntry(loc)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (az *azureRemoteStorageClient) readFileRemoteEntry(loc *remote_pb.RemoteStorageLocation) (*filer_pb.RemoteEntry, error) {
|
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 {
|
func toMetadata(attributes map[string][]byte) map[string]string {
|
||||||
metadata := make(map[string]string)
|
metadata := make(map[string]string)
|
||||||
for k, v := range attributes {
|
for k, v := range attributes {
|
||||||
if strings.HasPrefix(k, "X-") {
|
if strings.HasPrefix(k, s3_constants.AmzUserMetaPrefix) {
|
||||||
continue
|
metadata[k[len(s3_constants.AmzUserMetaPrefix):]] = string(v)
|
||||||
}
|
}
|
||||||
metadata[k] = string(v)
|
|
||||||
}
|
}
|
||||||
return metadata
|
return metadata
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue