MCPcopy
hub / github.com/flyteorg/flyte / DownloadFileFromStorage

Function DownloadFileFromStorage

flytecopilot/data/utils.go:62–77  ·  view source on GitHub ↗
(ctx context.Context, ref storage.DataReference, store *storage.DataStore)

Source from the content-addressed store, hash-verified

60}
61
62func DownloadFileFromStorage(ctx context.Context, ref storage.DataReference, store *storage.DataStore) (io.ReadCloser, error) {
63 // We should probably directly use stow!??
64 m, err := store.Head(ctx, ref)
65 if err != nil {
66 return nil, errors.Wrapf(err, "failed when looking up Blob")
67 }
68 if m.Exists() {
69 r, err := store.ReadRaw(ctx, ref)
70 if err != nil {
71 return nil, errors.Wrapf(err, "failed to read Blob from storage")
72 }
73 return r, err
74
75 }
76 return nil, fmt.Errorf("incorrect blob reference, does not exist")
77}
78
79// Downloads data from the given HTTP URL. If context is canceled then the request will be canceled.
80func DownloadFileFromHTTP(ctx context.Context, ref storage.DataReference) (io.ReadCloser, error) {

Callers 2

TestDownloadFromStorageFunction · 0.85
handleBlobMethod · 0.85

Calls 4

ErrorfMethod · 0.80
HeadMethod · 0.65
ExistsMethod · 0.65
ReadRawMethod · 0.65

Tested by 1

TestDownloadFromStorageFunction · 0.68