diff --git a/storage/2023-11-03/file/files/range_get.go b/storage/2023-11-03/file/files/range_get.go index 9b2dec4..7d2d4c5 100644 --- a/storage/2023-11-03/file/files/range_get.go +++ b/storage/2023-11-03/file/files/range_get.go @@ -3,6 +3,8 @@ package files import ( "context" "fmt" + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "io" "net/http" "strings" @@ -83,13 +85,19 @@ 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 + result.Contents = &[]byte{} + 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 { diff --git a/storage/2023-11-03/file/files/range_get_file.go b/storage/2023-11-03/file/files/range_get_file.go index e923eb3..2551c1e 100644 --- a/storage/2023-11-03/file/files/range_get_file.go +++ b/storage/2023-11-03/file/files/range_get_file.go @@ -93,6 +93,9 @@ func (c Client) GetFile(ctx context.Context, shareName, path, fileName string, i copy(output[v.startBytes:v.endBytes], *v.bytes) } + if result.OutputBytes == nil { + result.OutputBytes = &[]byte{} + } *result.OutputBytes = output return }