Welcome Guest, Not a member yet? Register   Sign In
What is the benefit of using force download
#2

(This post was last modified: 12-02-2015, 04:11 AM by JayAdra.)

You could generate a unique hash/code for each file you upload to your site (create an upload script on your site if you haven't already) and store the files in the DB with their hash.

Then display the download link as something like:

Code:
/download/SDFg39vTDp

You then have a route similar to:

Code:
download/(:any)

Which loads a controller where you can look up the file in the DB (using the hash), get the filepath (store this in the DB also) and force the output to the browser.

This will allow you to have unique, hashed download links which aren't (for the most part...) guessable or sequential. It also allows you to build in "secured" or "private" links if you wished, by adding logic to your controller to check for a password, or an active session before allowing the download.

Hope this helps!

PS: The other thing to consider is the fact that if you're selling files, someone could copy the link to the file they purchased, and then share that link anywhere they want. This is why you might want to consider building in some security around it or changing it so that when they purchase a file, it generates a one-time link which expires after a certain amount of time or a certain amount of downloads (or both).

This is probably the way to go to prevent people abusing your system.
Reply


Messages In This Thread
RE: What is the benefit of using force download - by JayAdra - 12-02-2015, 04:07 AM



Theme © iAndrew 2016 - Forum software by © MyBB