Skip to content

Commit

Permalink
azure: Upload Content-Type option (#223)
Browse files Browse the repository at this point in the history
* azure: Upload Content-Type option

* add changelog entry

---------

Co-authored-by: John Judd <john.judd@c2fo.com>
  • Loading branch information
NathanBaulch and funkyshu authored Jan 9, 2025
1 parent 7a10f16 commit be7e744
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [6.25.1] - 2025-01-09
### Fixed
- The intersection of features #208 and #213 was missed (during rebase).

## [6.25.0] - 2025-01-08
### Added
- Added NewFile option for Content-Type.
Expand Down
9 changes: 8 additions & 1 deletion backend/azure/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/Azure/azure-sdk-for-go/sdk/azcore/streaming"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blob"
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blockblob"
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/container"

"github.com/c2fo/vfs/v6"
Expand Down Expand Up @@ -110,7 +111,13 @@ func (a *DefaultClient) Upload(file vfs.File, content io.ReadSeeker, contentType
if !ok {
body = streaming.NopCloser(content)
}
_, err = blobURL.Upload(context.Background(), body, nil)
var opts *blockblob.UploadOptions
if contentType != "" {
opts = &blockblob.UploadOptions{
HTTPHeaders: &blob.HTTPHeaders{BlobContentType: &contentType},
}
}
_, err = blobURL.Upload(context.Background(), body, opts)
return err
}

Expand Down

0 comments on commit be7e744

Please sign in to comment.