From 87fa9f8e463c93e9d366d81caa2fae75c5d0bb9d Mon Sep 17 00:00:00 2001 From: rkettelerij Date: Mon, 14 Nov 2022 10:51:49 +0100 Subject: [PATCH] azureblob: Add support for custom upload headers --- backend/azureblob/azureblob.go | 20 ++++++++++++++++++++ docs/content/azureblob.md | 12 ++++++++++++ 2 files changed, 32 insertions(+) diff --git a/backend/azureblob/azureblob.go b/backend/azureblob/azureblob.go index 8c49a50dd..6c46419f5 100644 --- a/backend/azureblob/azureblob.go +++ b/backend/azureblob/azureblob.go @@ -1685,6 +1685,26 @@ func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, op } } + // Apply upload options (also allows one to overwrite content-type) + for _, option := range options { + key, value := option.Header() + lowerKey := strings.ToLower(key) + switch lowerKey { + case "": + // ignore + case "cache-control": + httpHeaders.CacheControl = value + case "content-disposition": + httpHeaders.ContentDisposition = value + case "content-encoding": + httpHeaders.ContentEncoding = value + case "content-language": + httpHeaders.ContentLanguage = value + case "content-type": + httpHeaders.ContentType = value + } + } + uploadParts := maxUploadParts if uploadParts < 1 { uploadParts = 1 diff --git a/docs/content/azureblob.md b/docs/content/azureblob.md index 5a1e2663f..6f0200b3b 100644 --- a/docs/content/azureblob.md +++ b/docs/content/azureblob.md @@ -514,6 +514,18 @@ Properties: {{< rem autogenerated options stop >}} +### Custom upload headers + +You can set custom upload headers with the `--header-upload` flag. + +- Cache-Control +- Content-Disposition +- Content-Encoding +- Content-Language +- Content-Type + +Eg `--header-upload "Content-Type: text/potato"` + ## Limitations MD5 sums are only uploaded with chunked files if the source has an MD5