diff --git a/backend/azureblob/azureblob.go b/backend/azureblob/azureblob.go index c7e43ecb4..9e509c89c 100644 --- a/backend/azureblob/azureblob.go +++ b/backend/azureblob/azureblob.go @@ -519,6 +519,7 @@ type Object struct { mimeType string // Content-Type of the object accessTier blob.AccessTier // Blob Access Tier meta map[string]string // blob metadata - take metadataMu when accessing + tags map[string]string // blob tags } // ------------------------------------------------------------ @@ -1876,6 +1877,14 @@ func (o *Object) decodeMetaDataFromBlob(info *container.BlobItem) (err error) { return nil } +func (o *Object) getTags() (tags map[string]string) { + if o.tags != nil { + return o.tags + } + + return map[string]string{} +} + // getBlobSVC creates a blob client func (o *Object) getBlobSVC() *blob.Client { container, directory := o.split() @@ -2226,6 +2235,7 @@ func (w *azChunkWriter) Close(ctx context.Context) (err error) { options := blockblob.CommitBlockListOptions{ Metadata: w.o.getMetadata(), + Tags: w.o.getTags(), Tier: parseTier(w.f.opt.AccessTier), HTTPHeaders: &w.ui.httpHeaders, } @@ -2281,6 +2291,7 @@ func (o *Object) uploadSinglepart(ctx context.Context, in io.Reader, size int64, options := blockblob.UploadOptions{ Metadata: o.getMetadata(), + Tags: o.getTags(), Tier: parseTier(o.fs.opt.AccessTier), HTTPHeaders: &ui.httpHeaders, } @@ -2351,6 +2362,20 @@ func (o *Object) prepareUpload(ctx context.Context, src fs.ObjectInfo, options [ switch lowerKey { case "": // ignore + case "x-ms-tags": + if o.tags == nil { + o.tags = make(map[string]string) + } + + tags := strings.Split(value, ",") + for _, tag := range tags { + parts := strings.SplitN(tag, "=", 2) + if len(parts) != 2 { + return ui, fmt.Errorf("invalid tag %q", tag) + } + + o.tags[parts[0]] = parts[1] + } case "cache-control": ui.httpHeaders.BlobCacheControl = pString(value) case "content-disposition": diff --git a/docs/content/azureblob.md b/docs/content/azureblob.md index f95f1299a..cd0f9b7b2 100644 --- a/docs/content/azureblob.md +++ b/docs/content/azureblob.md @@ -896,8 +896,9 @@ You can set custom upload headers with the `--header-upload` flag. - Content-Encoding - Content-Language - Content-Type +- X-MS-Tags -Eg `--header-upload "Content-Type: text/potato"` +Eg `--header-upload "Content-Type: text/potato"` or `--header-upload "X-MS-Tags: foo=bar"` ## Limitations