Share and create grants for single objects using go-uplink

Hey there,

I recently started building a system using StorJ as the file storage. I use the uplink sdk for Go and so far everything works really smoth (compliments to the devs) :slight_smile:

Now I was wondering, the Uplink CLI has the option to create grants and share objects, like this example from the docs

uplink share sj://cakes/cheesecake.jpg

Am I right to assume this function does not exist in the uplink sdk? (at least i couldnt find it)

Its gonna be quite crucial for my App to be able to programatically create and share and Access Token for objects.

Any recommendation on how i could achieve this?

Thanks in advance.

Looking at the documentation I found this: uplink package - storj.io/uplink - Go Packages.
I have no idea of go, but hope it still helps you.

2 Likes

Yes, access.Share() should do the magic.

You can create a main access grant and derive more grants programmatically with limited access/permission. This is an offline operation and you don’t need to call any API. The generated grants can be used independently, when you delete the main one, all the children will be invalidated, too…

In case you are interested the underlying technology, Access grant includes

  1. the satellite address
  2. the API key which includes all the allowed permissions and a signature (this part can be further restricted)
  3. secret password used to decrypt the data

This illustration shows the structure:

And this shows why is it possible to derive restricted API keys:

But it’s not strictly required, you can use access.Share.

Please note that if you plan to use S3 or HTTP protocol (using linksharing or gateway-mt), you should register the generated grant with the help of uplink/edge at d68206c01ceb3140e9ec6a3456f285fed7ea0d0e · storj/uplink · GitHub

This is not required if you only use pure go upload/download.

3 Likes

I think thats what i was looking for! Thanks a lot, i will try it out :slight_smile: