S3 Get File vs Sign Download URL from DO Spaces

I'm looking to have files only read through my app, not available through the browser (http://web.co/filename). I'm looking into a modal. Files could be anything (pdf, docx, etc). At this point their housed in bucket marked private in Digital Oceans Spaces.

I have Get file and Sign download both working up to the point of the file downloads. I have two questions:

  1. What is the difference between them?
  2. Suggestions on how to get the files visiable via an iframe in a modal instead of a url. I have the iframe working - just can't grasp the process to show in a modal

You mean to not expose any URL on the client side? If yes:
Its probably impossible since you will have to call some URL to get the file from the remote server - be it via your server or S3 directly.
But, you can make the URL such that it uses some single-use token. So the exact same URL would run only once, return the file data (as a blob or stream or base64 string) and will not be accessible again without generating another token.

To show the files in a modal, check out the code here. Should give you some idea: Secure Share
Here data is received from server as a string, and then shown in a modal after some processing.

Any guidance or insight you can provide to the difference between Get File and Sign Download URL?

Get File: Downloads the file on your server, which you can access server side only. To allow client side to download it, you will need to add another Download File step, and make sure the SA is called from the Download component on the page (or directly in the browser address bar).

Sign Download URL: Create a secure link to the file stored directly in S3. This is usually done to send the link to client side, to download the file - without having to download it on your server as above.

image

Sign Download Url would be the best workaround for you for now.. since you can set the timeout to a very low value - something that would be enough for the file to be rendered/downloaded on the client side.

2 Likes