I uploaded a text file to my Storj bucket at a specific upload path.
Now, I want to download this file, which I uploaded, so I wrote the following lines:
// Open file
obj, err := bucket.OpenObject(ctx, “test/log.txt”)
if err != nil {
return err
}
defer errCatch(obj.Close)
// Get a reader for the entire file
r, err := obj.DownloadRange(ctx, 0, -1)
if err != nil {
return err
}
defer errCatch(r.Close)
Now, I just want that the los.txt which I uploaded earlier gets downloaded to my present working directory.
By using ioutil, I am only able to read the file and print it.
Please guide me.