Skip to content

Commit

Permalink
Adding content type for azureblobstorage output (#50)
Browse files Browse the repository at this point in the history
* Adding content type for azureblobstorage

* update changelog and go mod

* go mod tidy
  • Loading branch information
P1llus authored Jan 25, 2023
1 parent b0c8885 commit 7ae2356
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ This project adheres to [Semantic Versioning](http://semver.org/).

### Removed

## [0.9.1]

### Changed

- Modified azureblobstorage output to use correct content type header: [#50](https://github.com/elastic/stream/pull/50)

## [0.9.0]

### Added
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.19
require (
cloud.google.com/go/pubsub v1.25.1
cloud.google.com/go/storage v1.28.0
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.5.1
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.6.1
github.com/Shopify/sarama v1.36.0
github.com/elastic/go-concert v0.2.0
github.com/elastic/go-lumber v0.1.2-0.20220819171948-335fde24ea0f
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.1.4/go.mod h1:uGG2W01BaETf0Ozp+Q
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0 h1:QkAcEIAKbNL4KoFr4SathZPhDhF4mVwpBMFlYjyAqy8=
github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.1 h1:XUNQ4mw+zJmaA2KXzP9JlQiecy1SI+Eog7xVkPiqIbg=
github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.1/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w=
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.5.1 h1:BMTdr+ib5ljLa9MxTJK8x/Ds0MbBb4MfuW5BL0zMJnI=
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.5.1/go.mod h1:c6WvOhtmjNUWbLfOG1qxM/q0SPvQNSVJvolm+C52dIU=
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.6.1 h1:YvQv9Mz6T8oR5ypQOL6erY0Z5t71ak1uHV4QFokCOZk=
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.6.1/go.mod h1:c6WvOhtmjNUWbLfOG1qxM/q0SPvQNSVJvolm+C52dIU=
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8=
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1 h1:BWe8a+f/t+7KY7zH2mqygeUD0t8hNFXe08p1Pb3/jKE=
Expand Down
9 changes: 8 additions & 1 deletion pkg/output/azureblobstorage/azure_blob_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/elastic/stream/pkg/output"

"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob"
blobalias "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blob"
)

func init() {
Expand Down Expand Up @@ -47,7 +48,13 @@ func (*Output) Close() error {
}

func (o *Output) Write(b []byte) (int, error) {
_, err := o.client.UploadBuffer(context.Background(), o.opts.AzureBlobStorageOptions.Container, o.opts.AzureBlobStorageOptions.Blob, b, nil)
cType := "application/json"
options := azblob.UploadBufferOptions{
HTTPHeaders: &blobalias.HTTPHeaders{
BlobContentType: &cType,
},
}
_, err := o.client.UploadBuffer(context.Background(), o.opts.AzureBlobStorageOptions.Container, o.opts.AzureBlobStorageOptions.Blob, b, &options)
if err != nil {
return 0, fmt.Errorf("failed to upload file to blob: %w", err)
}
Expand Down

0 comments on commit 7ae2356

Please sign in to comment.