Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Download External Resource - Rename File

I have a site where users are prompted to download files from external resources. Since the external file names are hashed and the user downloads multiple files, it's very hard for users to know which file they download reaches what resource they requested. For instance, the file name of fdae442dafe42.zip could be production-resources.zip.

I'm looking for ways to have it so the browser will download the file as a different name. Below are some of my ideas and why they won't work, but you may be able to find a workaround.

Just a note, I don't have any control over the external resource. I won't be able to make changes to the headers or anything else. My service is a website that mostly targets Desktop Users. Android and iOS solutions won't be that beneficial.

Download Attribute

This method was working for a while in Google Chrome and Firefox, but then they started to follow the W3 HTML5 spec. The external resource requires to send the header of Content-Disposition in which Google Chrome and Firefox didn't check before.

PHP Proxy Download

I know that I could have a PHP script make a request to the external resource and then deliver it to the end user while changing the headers and name to fit my needs. The issue is the site has high traffic and each user downloads about 1-2GB of data. My servers are not able to handle this type of traffic and upgrading the server will probably be too costly.

Rename Files with External Application

I was considering using an external application (Possibly a Chrome / Firefox Extension) that will rename the files after they finish downloading. But considering a large enough of my audience are one time visitors, asking them to download an application or extension is very unlikely.

Flash or Java Embedded Solutions

I am considering using a Java or Flash embedded file that will handle the file downloads, but I don't know enough about either platform. From what I can tell, Flash doesn't have much control over the user's file system, so this could be an issue. Java will be able to do this task, but I was really hoping I wouldn't have to use Java since it's often insecure and requires a large download to install it (same issue as External Software idea).


If you have any ideas on what I could possibly do to solve this issue, they would be greatly appreciated. I'm not looking for any code, just ideas on how I will be able to accomplish the above task. I would like to thank you all for your time and expertise.

like image 885
David Avatar asked Jul 19 '14 03:07

David


People also ask

How do you rename a file path?

Right-click on the item and select Rename, or select the file and press F2 . Type the new name and press Enter or click Rename.

How do I rename a VB file?

Use the RenameFile method of the My. Computer. FileSystem object to rename a file by supplying the current location, file name, and the new file name. This method cannot be used to move a file; use the MoveFile method to move and rename the file.


1 Answers

What is this external resource you are referring to?

If it happens to be Amazon's S3, it allows you to generate download URLs and specify the Content-Disposition that should be present in the response from their server upon download. There you can encode what the filename the browser should use when saving the file.

If it's another service, take a look at its documentation, maybe it has similar feature.

like image 95
klandaika Avatar answered Oct 06 '22 07:10

klandaika