azureblob: Add support for custom upload headers

This commit is contained in:
rkettelerij 2022-11-14 10:51:49 +01:00 committed by Nick Craig-Wood
parent 1392793334
commit 87fa9f8e46
2 changed files with 32 additions and 0 deletions

View File

@ -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 uploadParts := maxUploadParts
if uploadParts < 1 { if uploadParts < 1 {
uploadParts = 1 uploadParts = 1

View File

@ -514,6 +514,18 @@ Properties:
{{< rem autogenerated options stop >}} {{< 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 ## Limitations
MD5 sums are only uploaded with chunked files if the source has an MD5 MD5 sums are only uploaded with chunked files if the source has an MD5