package storage import ( "context" "fmt" "io" ) // WriterDownloader is implemented by storage backends that stream an object // into a caller-owned file handle. type WriterDownloader interface { DownloadTo(ctx context.Context, key string, destination io.Writer) error } // DownloadTo streams one object into destination. Destination-confined callers // require this capability rather than granting a backend a mutable pathname. func DownloadTo(ctx context.Context, store ObjectStore, key string, destination io.Writer) error { writer, ok := store.(WriterDownloader) if !ok { return fmt.Errorf("object store does not support handle-confined downloads") } return writer.DownloadTo(ctx, key, destination) }