Skip to content

Commit

Permalink
file/files: fixing a bug in Get File where we'd try and unmarshal t…
Browse files Browse the repository at this point in the history
…he file
  • Loading branch information
tombuildsstuff committed Apr 5, 2024
1 parent 29e7fd4 commit 57ad29f
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions storage/2023-11-03/file/files/range_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package files
import (
"context"
"fmt"
"github.com/hashicorp/go-azure-helpers/lang/pointer"
"io"
"net/http"
"strings"

Expand Down Expand Up @@ -83,13 +85,18 @@ func (c Client) GetByteRange(ctx context.Context, shareName, path, fileName stri
var resp *client.Response
resp, err = req.Execute(ctx)
if resp != nil && resp.Response != nil {
result.Contents = &[]byte{}
result.HttpResponse = resp.Response

err = resp.Unmarshal(result.Contents)
if err != nil {
err = fmt.Errorf("unmarshalling response: %+v", err)
return
if resp.Body != nil {
respBody, err := io.ReadAll(resp.Body)
defer resp.Body.Close()
if err != nil {
return result, fmt.Errorf("could not parse response body")
}

if respBody != nil {
result.Contents = pointer.To(respBody)
}
}
}
if err != nil {
Expand Down

0 comments on commit 57ad29f

Please sign in to comment.