| 60 | } |
| 61 | |
| 62 | func 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. |
| 80 | func DownloadFileFromHTTP(ctx context.Context, ref storage.DataReference) (io.ReadCloser, error) { |