cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Get summer ready with Dropbox basic - travel documents, plans, progress reminders and more, right over here.

Discuss Dropbox Developer & API

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Content-Disposition in dropbox

Content-Disposition in dropbox

codingnightmare
Explorer | Level 4

Is there a way to rename a file while downloading from dropbox without changing the filename itself :

For example:

Dropbox link : https://www.dropbox.com/s/b06pn1n7w75ihyz/270px-July_Morning_Boby_Dimitrov.jpg?dl=1

and get file dow0nloaded: morning.jpg instead of 270px-July_Morning_Boby_Dimitrov.jpg

Content-Disposition header didn't work for me .

Any ideas how to do that ?

I recently developed a activestorage-dropbox gem for rails that wraps the Dropbox Storage Service as an Active Storage service. I am hoping the Content-Disposition functionality in dropbox as it's very much important for maintaining the robustness and quality of the functionality.    

https://github.com/ashishprajapati/activestorage-dropbox

Thanks 
Ashish Prajapati
Rails Contributor

9 Replies 9

Re: Content-Disposition in dropbox

Greg-DB
Dropboxer

The filename in Dropbox, and thereby in the shared link, is set when the file is uploaded. The vaue in the 'content-disposition' response header will also be based on that filename in Dropbox.

It sounds like you want to change the filename for your resulting local copy of the file when downloading from a shared link, not the filename in Dropbox itself.

Since that affects the file being written locally, exactly how you do that would depend on the HTTPS client you're using to download and write the file locally.

For example, using 'curl' like this would result in a file named "270px-July_Morning_Boby_Dimitrov.jpg?dl=1":

 

curl -L -O "https://www.dropbox.com/s/b06pn1n7w75ihyz/270px-July_Morning_Boby_Dimitrov.jpg?dl=1"

 

That option takes the filename from the URL.

Whereas using 'curl' like this would result in a file named "270px-July_Morning_Boby_Dimitrov.jpg":

curl -L -OJ "https://www.dropbox.com/s/b06pn1n7w75ihyz/270px-July_Morning_Boby_Dimitrov.jpg?dl=1"

That option takes the filename from the header.

And using 'curl' like this would result in a file named "morning.jpg":

curl -L -o "morning.jpg" "https://www.dropbox.com/s/b06pn1n7w75ihyz/270px-July_Morning_Boby_Dimitrov.jpg?dl=1"

That option takes the filename as specified on the command line.

I recommend referring to the documentation for whatever client you're using for information on how to set the local filename.

 

Re: Content-Disposition in dropbox

codingnightmare
Explorer | Level 4
I want the user to download the file from dropbox by adding a parameter or http header to the link and get the file with the new name, not through another server or rename it locally. I want dropbox to download the file with new name that I will pass in content-disposition headers or other params. I really need this functionality 😞

Well, with in active storage, we never stores the files with their real name. We just name it with some unique number or id and we stores the real name in our database. So what we really want, we want a way to pass a the real name in some header or parameters and it will use this name for the file directly at dropbox for downloading it. And will not affect the file.

Re: Content-Disposition in dropbox

codingnightmare
Explorer | Level 4
Greg, If you will check these links then you will realise that what I am exactly looking for:

Similar think is possible at GCS:
https://stackoverflow.com/questions/21026132/google-cloud-storage-download-a-file-with-a-different-n...

Similar thing is possible with S3:
https://stackoverflow.com/questions/2611432/amazon-s3-change-file-download-name/2612795#2612795

Thanks

Re: Content-Disposition in dropbox

Greg-DB
Dropboxer

I see, thanks for clarifying. Dropbox unfortunately doesn't offer an option for setting the download name like that. 

Re: Content-Disposition in dropbox

codingnightmare
Explorer | Level 4
Oh, I had thought that DROPBOX allows passing custom-disposition attributes i.e name with in headers for downloading the file with any name required. It was required for my one of the important project that was the part of Ruby On Rails ActiveStorage module. It will create big problem for us because we don’t want to save real file name there at storage providers, we want to keep the real name in our database. We are just using some random unique number for the file names.

At the moment, we are using AWS S3, GCS and AZURE storage providers for storing and delivery files with Rails ActiveStorage.
We thought of using Dropbox too but it’s one the key feature for the security of using content-disposition headers to download file with any name not supported by dropbox.

Is there any chances to develop it ? I can help as well. It’s one of the important key feature that will be widely be useful for bulk of developer whoever using dropbox and want to use custom-disposition headers. And will also help Rails Community as we want to use dropbox as a ActiveStorage storage provider 🙂 I am happy to discuss more.

Thanks,
Ashish Prajapati
CEO, Clecotech | Rails Contributor

Re: Content-Disposition in dropbox

Greg-DB
Dropboxer

I'll pass this along as a feature request. I can't promise if or when that might be implemented though, so I recommend trying to accomplish this locally instead.

Re: Content-Disposition in dropbox

codingnightmare
Explorer | Level 4
Ok, I will ask the same with Rails Core Team and will discuss that, it’s better to store the files with real name directly at dropbox and will create the folders with unique number for identifying the path etc. i.e 356663/ashish.jpg in place of 35663 only 🙂

I will release the new version of ‘activestorage-dropbox gem’ with this small improvement so at least end users can see the real name after downloading the file.

I will also wait for you so if there will be any news about implementing the Content-disposition support by Dropbox then it will really help me and other bulk of developers those need the same. I checked the stackeoverflow and lots of developer asking for the same kind of thing with Dropbox

Thanks for your time Greg 🙂
Have a nice day 😉

Ashish P.

Re: Content-Disposition in dropbox

spotloader
Explorer | Level 3

Do you know when this feature will be available?

Re: Content-Disposition in dropbox

Greg-DB
Dropboxer

@spotloader This feature request was filed with the team, but I don't see any plans to implement it currently.

Poll
Which Dropbox Plan do you have?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropboxer
  • User avatar
    spotloader Explorer | Level 3
  • User avatar
    codingnightmare Explorer | Level 4
What do Dropbox user levels mean?
Need more support?