Sungpah Lee Sungpah Lee - 6 months ago 19x
Ruby Question

How to make users to download files in Dropbox with Ruby?

I'm now trying to make a function that allows users to access to the link of the file to download.

The native link is but, it is only accessible by admin ( for sure ). If I have a user who is eligible to know this link, then I would love to allow this user to click some button to download the file.

I am kind of bogged down when it comes to implementation. Because if I use the below code, it seems it stores data into the server.

def self.dropbox_download
contents, metadata = Drop_client.get_file_and_metadata('/lesson_id_12:user_id_7.mp3.mp3')
begin'filename.mp3', 'wb') do |file|

I want to make user to click something and the "mp3" file will be downloaded, but I don't think the above code works in this way.

Please shoot any opinion! I'm looking forward to seeing!



If you only need to allow other users to download this specific file (or some specific set of files), the easiest way is to just get a shared link to the relevant file(s):

You can modify these shared links for different behaviors, e.g., for file downloads, as shown here:

If you do need to get these links programmatically, you can use the shares method:

You can then give the shared link to the user, e.g., as a link on a web page, or in an email, etc.