Drupal module to make user wait before download of any file
To present a file for download, first install the anu_download_wait module. I use brtDownloadPostRequest.pl file to quickly generate the "Download" button. It looks something like:
This is because mine is shared hosting and download of big files will choke my account and also all files should be present in my site as a backup by default.
So if
My requirement
I want to every visitor to wait before downloading any file. Also I don't want the search engines to index the download file. I earn from ads so the more visitors see them, the better for me.How to do it
It is best done using POST form submission, which will make search engines to automatically stop there. This POST data will contain the file to download, wait delay the user will need to wait before downloading the file.Functionality
You can find actual implementation here.To present a file for download, first install the anu_download_wait module. I use brtDownloadPostRequest.pl file to quickly generate the "Download" button. It looks something like:
<form method="post" action="http://127.0.0.1/bookrailticket/downloadsbrt/90n-brt-download-file-now" class="com_download_showpage_form">
<input type="hidden" value="http://127.0.0.1/bookrailticket/200812-48539a7b9-indian-rail-route-map-p09" name="anu_download_file_link" />
<input type="hidden" value="1" name="anu_download_wait_delay_factor" />
<input type="hidden" value="Indian Railways Route Map" name="anu_download_file_title" />
<input type="submit" title="Press this button to download the document" value="Download" class="submitBtn1" />
</form>
Mind you it contains following changeable values:anu_download_file_link
: Set it to wherever the download is present. After wait is over, visitor will be taken to this pageanu_download_wait_delay_factor
(optional): How many seconds the visitor will wait( 1- 300 secs). Any other value will have it reset to 45 second in the moduleanu_download_file_title
: This title will be shown in the download page.
Javascript Issues
If javascript is disabled then the download button is shown enabled. So it will work by default. Also unless jquery & Drupal library is fully loaded the "Download" button will show as enabled and as soon as it is fully loaded, the javascript code will hide it and re-enable it after the wait period.Redirect Feature
There is another redirect feature I've added is that if in the link the file is present in within your site then you can create a file in the same folder with the same name but with ".redirect" suffix added and put the redirected url in it, then the download will be redirect to this location. White space is not a problem in .redirect file.This is because mine is shared hosting and download of big files will choke my account and also all files should be present in my site as a backup by default.
So if
anu_download_file_link
is set to "http://www.example.com/sites/default/files/abc.pdf" then just upload this file in say DropBox, Hotfile etc and put that link in the file: sites/default/files/abc.pdf.redirect in your site. So even if you remove this redirect file your downloads keep working!
No comments:
Post a Comment