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

Function UploadFileToStorage

flytecopilot/data/utils.go:48–60  ·  view source on GitHub ↗

Uploads a file to the data store.

(ctx context.Context, filePath string, toPath storage.DataReference, size int64, store *storage.DataStore)

Source from the content-addressed store, hash-verified

46
47// Uploads a file to the data store.
48func UploadFileToStorage(ctx context.Context, filePath string, toPath storage.DataReference, size int64, store *storage.DataStore) error {
49 f, err := os.Open(filePath)
50 if err != nil {
51 return err
52 }
53 defer func() {
54 err := f.Close()
55 if err != nil {
56 logger.Errorf(ctx, "failed to close blob file at path [%s]", filePath)
57 }
58 }()
59 return store.WriteRaw(ctx, toPath, size, storage.Options{}, f)
60}
61
62func DownloadFileFromStorage(ctx context.Context, ref storage.DataReference, store *storage.DataStore) (io.ReadCloser, error) {
63 // We should probably directly use stow!??

Callers 2

TestUploadFileFunction · 0.85
handleBlobTypeMethod · 0.85

Calls 4

ErrorfFunction · 0.92
OpenMethod · 0.80
WriteRawMethod · 0.65
CloseMethod · 0.45

Tested by 1

TestUploadFileFunction · 0.68