diff options
-rw-r--r-- | local.go | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -215,17 +215,18 @@ func (a *LocalConn) DelFromQueue(url string, handle string) error { // Download just copies the file from TempDir/bucket/key to path func (a *LocalConn) Download(bucket string, key string, path string) error { - f, err := os.Create(path) + fin, err := os.Open(filepath.Join(a.TempDir, bucket, key)) if err != nil { return err } - defer f.Close() + defer fin.Close() - fin, err := os.Open(filepath.Join(a.TempDir, bucket, key)) + f, err := os.Create(path) if err != nil { return err } - defer fin.Close() + defer f.Close() + _, err = io.Copy(f, fin) return err } |