implementing download using a url call

T

tanmay.kansara

Hey Guys,

here is what I am trying to solve.

I have a URL - somesite.com/server/pattern.x?some_more_stuff

This URl is out there as an href tag on users website. Is there a way in which I can serve a file(not from my server) while ensuring that the users remain on the third party website. I am currently using this :

myfile = "http://download.someothersite.com/somefile.exe"

meta_tag = "<html><head><meta http-equiv='Refresh' Content='1;URL=%s'></head></html>" % myfile
return HttpResponse(meta_tag, content_type='force-download')

The above works, however the user gets redirected to a blank page. Would downloading and serving the file from my server be a better option? If so, some pointers please.

Do let me know what would be an elegant solution. The file sizes should be about 500kb(stub files).

Thanks
 
C

Chris Angelico

Hey Guys,

here is what I am trying to solve.

I have a URL - somesite.com/server/pattern.x?some_more_stuff

This URl is out there as an href tag on users website. Is there a way in which I can serve a file(not from my server) while ensuring that the users remain on the third party website. I am currently using this :

myfile = "http://download.someothersite.com/somefile.exe"

meta_tag = "<html><head><meta http-equiv='Refresh' Content='1;URL=%s'></head></html>" % myfile
return HttpResponse(meta_tag, content_type='force-download')

The above works, however the user gets redirected to a blank page. Would downloading and serving the file from my server be a better option? If so, some pointers please.

So what you want is for the user to go to a page which both downloads
a file *and* displays content, is that it?

This is fairly common on the web today; have a look at how places like
Sourceforge do it.

ChrisA
 
T

tanmay.kansara

Hey

Sorry, I should make it more clear. We had a 3rd party that was serving stub builds and they have their URLs on various pages(random sites). We control the sub-domain, so i can send that traffic to wherever I want. I am looking to create logic that takes that incoming parameter and serves an exe file.
With the logic I posted, the user gets the file, but also gets a new blank page. I would like to keep the user on the 3rd part website.

Hope this clarifies.

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top