Uploads a file to the data store.
(ctx context.Context, filePath string, toPath storage.DataReference, size int64, store *storage.DataStore)
| 46 | |
| 47 | // Uploads a file to the data store. |
| 48 | func 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 | |
| 62 | func DownloadFileFromStorage(ctx context.Context, ref storage.DataReference, store *storage.DataStore) (io.ReadCloser, error) { |
| 63 | // We should probably directly use stow!?? |