How can I access private files on Spaces using GET?

March 3, 2018 3.6k views
DigitalOcean

Hi,
I am trying to access private files from my Spaces, I have not found any way to access my files through the GET method. I have a secret and a key id, the standard credentials, are there any variables I can use in order to access my private files using my id and secret?
For example, something like:
{bucket-name}.{location}.digitaloceanspaces.com/PRIVATE-FILE?id={my-id}&secret={my-secret}
I really need help with this, if it is not possible, please can someone instruct me on how to access private files using the aws-sdk.
Thank you very much

3 Answers

Spaces was designed to be compatible with the S3 API in order to allow users to leverage existing tools. Accessing private files requires generating a signature for authentication. As this is quite complicated, you should generally use an existing library in your programing language of choice.

Check out this question for examples in a number of languages:

Let us know more about how you are trying to access the files, and we can provide a more specific answer.

Hi,
We are trying to access the Private files from Spaces using Elfinder File Manager. But not able to access when it is having Private Access. So we are not able to access unless we give them Public Access which is may not good for the application. If we give Public access people can access using URL through any browser without any permissions.

We are able to upload files to the Spaces also, but not able to access same file that we just uploaded. So we would like to upload/access the files with Private access through Elfinder File Manager.

Currently we are using S3 Adapter. Appreciate if any suggestions.

Thank you very much
Venu Kommu

I tried a few different libraries for generating an S4 signature (I have to confess I don't understand how to do it myself, the instructions are just too unclear) and I keep getting a SignatureDoesNotMatch error. I wonder if part of the problem might be that those libraries are optimized for AWS, and not DO?

  • Actually using the aws4 library I made some progress. Here's what happened, in case it helps anybody else. I was running into a NoSuchBucket error, with BucketName equal to "development". But my DO URL was

    https://zenshome.sgp1.digitaloceanspaces.com/development/contracts/XXn62kk4CPxvDBNEt-en.pdf

    Where development is the name of a directory, not the bucket… (that would be "zenshome").

    I actually had to change the URL to:

    https://zenshome.sgp1.digitaloceanspaces.com/zenshome/development/contracts/XXn62kk4CPxvDBNEt-en.pdf

    (note the second "zenshome")

    This seems to work, but it's not documented on DO as far as I can tell. I pretty much had to guess!

Have another answer? Share your knowledge.