0

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/uex431ou02h2m2b/300x50.gif?dl=1

and get file downloaded : NewNameImage.gif instead of 300x50.gif

Content-Disposition header didn't work for me .

any ideas how to do that ?

1 Answers1

0

If you're downloading the file locally you should either be able to control the name given to the local file, or be able to rename it after the fact. For example, using curl, -JO downloads the file using the remote name specified in the Content-Disposition header, while -o lets you specify a name:

$ curl -L -JO "https://www.dropbox.com/s/uex431ou02h2m2b/300x50.gif?dl=1"
...
curl: Saved to filename '300x50.gif'
$ ls
300x50.gif
$ rm 300x50.gif
$ curl -L -o "NewNameImage.gif" "https://www.dropbox.com/s/uex431ou02h2m2b/300x50.gif?dl=1"
...
$ ls
NewNameImage.gif

Alternatively, renaming it after the fact:

$ curl -L -JO "https://www.dropbox.com/s/uex431ou02h2m2b/300x50.gif?dl=1"
...
curl: Saved to filename '300x50.gif'
$ ls
300x50.gif
$ mv 300x50.gif "NewNameImage.gif"
$ ls
NewNameImage.gif
Greg
  • 16,359
  • 2
  • 34
  • 44
  • 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 . – Cfir Bitan Jun 30 '15 at 10:43
  • Oh, thanks for clarifying. If you're just supplying the link directly to the user in an HTML link then, where you don't actually control the server (Dropbox) or the client doing the downloading (the user's browser), I don't think you can control the resulting filename. – Greg Jun 30 '15 at 15:38