Skip to content

Commit b29ab40

Browse files
committed
add code example for abs download stream
1 parent 3e483b8 commit b29ab40

1 file changed

Lines changed: 31 additions & 2 deletions

File tree

pkg/skbn/abs.go

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313

1414
"github.com/Azure/azure-pipeline-go/pipeline"
1515
"github.com/Azure/azure-storage-blob-go/azblob"
16+
// "github.com/Azure/azure-sdk-for-go/storage"
1617
)
1718

1819
var err error
@@ -168,6 +169,32 @@ func DownloadFromAbs(ctx context.Context, iClient interface{}, path string, writ
168169
return err
169170
}
170171
a, c, p := initAbsVariables(pSplit)
172+
173+
// Section to be tested - START
174+
175+
// If this works (or a similar version of it)
176+
// we can replace the entire "Section to be replaced"
177+
// this acheiving a stream from ABS
178+
// To make this work - uncomment the 'storage' import
179+
// References:
180+
// https://medium.com/@matryer/introducing-stow-cloud-storage-abstraction-package-for-go-20cf2928d93c
181+
// https://github.com/graymeta/stow/blob/master/azure/item.go#L46
182+
183+
// var client storage.BlobStorageClient
184+
// reader, err := client.GetContainerReference(c).GetBlobReference(p).Get(nil)
185+
// defer reader.Close()
186+
// if err != nil {
187+
// return err
188+
// }
189+
// _, err = io.Copy(writer, reader)
190+
// if err != nil {
191+
// return err
192+
// }
193+
194+
// Section to be tested - END
195+
196+
// Section to be replaced - START
197+
171198
pl := iClient.(pipeline.Pipeline)
172199
cu, err := getContainerURL(pl, a, c)
173200
if err != nil {
@@ -187,9 +214,11 @@ func DownloadFromAbs(ctx context.Context, iClient interface{}, path string, writ
187214
return err
188215
}
189216

190-
// this is a workaround
191-
// we do not want to save the entire file to memory
217+
// this is a workaround - we do not want to save the entire file to memory
192218
writer.Write(dd.Bytes())
219+
220+
// Section to be replaced - END
221+
193222
return nil
194223
}
195224

0 commit comments

Comments
 (0)