Skip to content

Commit

Permalink
HOOK-1803 Switch to UploadBuffertoBlockBlob
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-leanix committed Apr 28, 2020
1 parent b8033e2 commit c7a8796
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions pkg/storage/azureblob.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import (
"context"
"errors"
"fmt"
"io/ioutil"
"net/url"
"os"

"github.com/Azure/azure-storage-blob-go/azblob"
)
Expand Down Expand Up @@ -67,20 +65,10 @@ func (u *AzureContainer) Upload(ldif []byte, log []byte) error {
}

func (u *AzureContainer) uploadFile(name string, content []byte) error {
filePath := fmt.Sprintf("/tmp/%s", name)
err := ioutil.WriteFile(filePath, content, 0700)
if err != nil {
return err
}

blobURL := azblob.ContainerURL(*u.Container).NewBlockBlobURL(name)
file, err := os.Open(filePath)
if err != nil {
return err
}

ctx := context.Background()
_, err = azblob.UploadFileToBlockBlob(ctx, file, blobURL, azblob.UploadToBlockBlobOptions{})
_, err := azblob.UploadBufferToBlockBlob(ctx, content, blobURL, azblob.UploadToBlockBlobOptions{})

return err
}

0 comments on commit c7a8796

Please sign in to comment.