rejetto forum

Software => HFS ~ HTTP File Server => Programmers corner => Topic started by: sunnygps on March 20, 2013, 09:23:36 PM

Title: Download a file irrespective of what is after the / in the URL
Post by: sunnygps on March 20, 2013, 09:23:36 PM
I have a requirement where we can have a number of users connect to the server and download a specific file. The request will be to a static IP address like http://192.168.1.10:8081/ but could also be like http://192.168.1.10:8081/?filename=xxx&version=33.xx.

My requirement at this time is to ignore what is after 8081/ and server them the file that is off the root folder.

I have tried the below 2 in Diff template, but it seems to not work. I see the "Requested GET" in the log windows, but the file specified never get download.

{.redirect|http://192.168.1.10:8081/d_custom.bin.}

[+not found]
{.add header|location: http://192.168.1.10:8081/d_custom.bin.}

Anyone can help me with the script? Eventuly, I would like to be able to parse the URL and server the appropriate file to request.

Thank you.
Title: Re: Download a file irrespective of what is after the / in the URL
Post by: sunnygps on March 21, 2013, 01:42:28 PM
Anyone?
Title: Re: Download a file irrespective of what is after the / in the URL
Post by: crazyboris on March 24, 2013, 11:18:47 AM
havent tryed this but what if you :
 rightclick on root
then properts
then diff template
add the "download code" there.
Title: Re: Download a file irrespective of what is after the / in the URL
Post by: sunnygps on March 24, 2013, 12:21:39 PM
I have already tried that and it did not work. What is working though, is the if I just one file off the "/" root, then then that file gets transfered irrespective of what the URL is.

I still need to figure out how to parse the URL and redirect to the appropriate file.

Thanks!
Title: Re: Download a file irrespective of what is after the / in the URL
Post by: rejetto on March 25, 2013, 09:01:06 AM
I didn't understand if you want to discard the value of filename=...
Title: Re: Download a file irrespective of what is after the / in the URL
Post by: sunnygps on March 25, 2013, 03:07:21 PM
I didn't understand if you want to discard the value of filename=...

The ultimate goal is to read the URL and based on the what is in the "filename" and "ver" redirect to the appropriate link (file) to be downloaded.

The first test I was doing was to just redirect to a link irrespective of what was after the ":8080/" in the URL. This way, all the "not found" and other errors messages could be ignored to amke sure what I was using the HFS for could be accomplished. Which it did.

Now I am on to figuring out how to read the URL and redirect based on what variable are being passed on.

Thanks!
Title: Re: Download a file irrespective of what is after the / in the URL
Post by: rejetto on March 31, 2013, 02:23:25 PM
the command is {.?filename.}
like in
{.redirect|http://192.168.1.10:8081/my_folder/{.?filename.}.}
Title: Re: Download a file irrespective of what is after the / in the URL
Post by: sunnygps on April 01, 2013, 03:15:44 AM
Thank you. One last question. How do I create a condition statement to store the value of the urlvar and then redirect to the appropriate file for download?

Thank you once again for your help.
Title: Re: Download a file irrespective of what is after the / in the URL
Post by: rejetto on April 21, 2013, 06:42:14 PM
conditions are made with the {.if.} command, but you didn't say what condition, neither you specified where you mean to store the value.