@@ -3,6 +3,7 @@ package skbn
33import (
44 "context"
55 "fmt"
6+ "io"
67 "log"
78 "math"
89 "path/filepath"
@@ -209,24 +210,24 @@ func GetListOfFiles(client interface{}, prefix, path string) ([]string, error) {
209210 return relativePaths , nil
210211}
211212
212- // Download downloads downloads a single file from path and returns a byte array
213- func Download (srcClient interface {}, srcPrefix , srcPath string , pw * nio. PipeWriter ) error {
213+ // Download downloads a single file from path into an io.Writer
214+ func Download (srcClient interface {}, srcPrefix , srcPath string , writer io. Writer ) error {
214215 ctx , cancel := context .WithCancel (context .Background ())
215216 defer cancel ()
216217
217218 switch srcPrefix {
218219 case "k8s" :
219- err := DownloadFromK8s (srcClient , srcPath , pw )
220+ err := DownloadFromK8s (srcClient , srcPath , writer )
220221 if err != nil {
221222 return err
222223 }
223224 case "s3" :
224- err := DownloadFromS3 (srcClient , srcPath , pw )
225+ err := DownloadFromS3 (srcClient , srcPath , writer )
225226 if err != nil {
226227 return err
227228 }
228229 case "abs" :
229- err := DownloadFromAbs (ctx , srcClient , srcPath , pw )
230+ err := DownloadFromAbs (ctx , srcClient , srcPath , writer )
230231 if err != nil {
231232 return err
232233 }
@@ -237,24 +238,24 @@ func Download(srcClient interface{}, srcPrefix, srcPath string, pw *nio.PipeWrit
237238 return nil
238239}
239240
240- // Upload uploads a single file provided as a byte array to path
241- func Upload (dstClient interface {}, dstPrefix , dstPath , srcPath string , pr * nio. PipeReader ) error {
241+ // Upload uploads a single file provided as an io.Reader array to path
242+ func Upload (dstClient interface {}, dstPrefix , dstPath , srcPath string , reader io. Reader ) error {
242243 ctx , cancel := context .WithCancel (context .Background ())
243244 defer cancel ()
244245
245246 switch dstPrefix {
246247 case "k8s" :
247- err := UploadToK8s (dstClient , dstPath , srcPath , pr )
248+ err := UploadToK8s (dstClient , dstPath , srcPath , reader )
248249 if err != nil {
249250 return err
250251 }
251252 case "s3" :
252- err := UploadToS3 (dstClient , dstPath , srcPath , pr )
253+ err := UploadToS3 (dstClient , dstPath , srcPath , reader )
253254 if err != nil {
254255 return err
255256 }
256257 case "abs" :
257- err := UploadToAbs (ctx , dstClient , dstPath , srcPath , pr )
258+ err := UploadToAbs (ctx , dstClient , dstPath , srcPath , reader )
258259 if err != nil {
259260 return err
260261 }
0 commit comments