This is a first time project that I’m experimenting with, so security - for the moment - isn’t something I’m looking to implement. I am currently unable to download an object from a bucket. I have 3 items that I can verify do exist in the bucket and was able to download it via uplink CLI manually. But doing it via the go lib
doesn’t seem to work.
What does work:
- getting access to the bucket
- access grant key
What doesn’t work:
- listing objects within the bucket
- download from the bucket
I’m using the below code to test out whether I’m able to print what’s being received just to see that that connection is going through. But I”m hitting an object not found
error that I’m not able to home in on. I double checked that I’m spelling everything correctly and that the keys match(tried regenerating them too), but I’m unfortunately not able to do a thing even with the permissions elevated to `fully.
I’m wondering if I’m supposed to do something with the satellite key? But this is purely an assumption and so I”m hoping someone might be able to provide me with the correct flow, as the tutorial shown via gh didn’t help this time around.
Below is the code I quickly hacked up to get things working. Please let me know if I’ve done something wrong here. I’m fetching the keys via a `.env file and that seems to be working just fine. Although to be sure I did verify it by using string literals.
func downloadData(ctx context.Context, env Env, data []byte) error {
1
2 // verification steps
3 project, shouldReturn, returnValue := verifyStorj(env, ctx)
4 if shouldReturn {
5 return returnValue
6 }
7
8 download, err := project.DownloadObject(ctx, env.bucketName, env.objectKey, nil)
9 if err != nil {
10 return fmt.Errorf("could not download from bucket: %v", err)
11 }
12
13 defer download.Close()
14
15 receivedContents, err := ioutil.ReadAll(download)
16 if err != nil {
17 return fmt.Errorf("couldn't read all download data: %v", err)
18 }
19
20 fmt.Printf("received contents are: %v", receivedContents)
21
22 if !bytes.Equal(receivedContents, data) {
23 return fmt.Errorf("different object obtained: %q != %q", data, receivedContents)
24 }
25 return nil
26 }