Download file

View: New views
4 Messages — Rating Filter:   Alert me  

Download file

by luca72 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hello
i have write this:
@expose()
    def scarica(self, ID):
        from cherrypy.lib.static import serve_file
        b= Invio.get(ID)
        nome = b.fileinv
        return serve_file('/home/luca/Desktop/Turbogears/file/file/
static/fl/'+nome,"application/x-download", "attachment", nome)
The browser don't open the download dialog it open a new page with the
file opened
Can you help me?
Regards

Luca



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users@...
To unsubscribe from this group, send email to cherrypy-users-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Download file

by cmhofer@gmail.com :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Am Sun, 22 Jun 2008 03:17:55 -0700 (PDT)
schrieb luca72 <lucaberto@...>:

>
> Hello
> i have write this:
> @expose()
>     def scarica(self, ID):
>         from cherrypy.lib.static import serve_file
>         b= Invio.get(ID)
>         nome = b.fileinv
>         return serve_file('/home/luca/Desktop/Turbogears/file/file/
> static/fl/'+nome,"application/x-download", "attachment", nome)
> The browser don't open the download dialog it open a new page with the
> file opened
> Can you help me?
> Regards
>
> Luca
>
>

if it is a txt file i can be a problem of your browser that opens the
file instead of downloading it.

I don't know the sytnax for serve_file but i have no lase parameter
nome" and it works.

return serve_file(vpath+vfile, "application/x-download","attachment")

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users@...
To unsubscribe from this group, send email to cherrypy-users-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Download file

by luca72 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



Thanks For your reply the problem is that it open also for example a
zip file and you see in your web a lot of crazy  syntax:

Nome is the file name i have also try whit your syntax but nothing is
change.

Regards

Luca


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users@...
To unsubscribe from this group, send email to cherrypy-users-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Download file

by Eric Abrahamsen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


As a last resort you can try serving it as 'application/octet-stream',  
which more or less tells browsers "you're not going to be able to  
handle this, don't even try to display it". See if that works...


On Jun 23, 2008, at 5:56 PM, luca72 wrote:

>
>
> Thanks For your reply the problem is that it open also for example a
> zip file and you see in your web a lot of crazy  syntax:
>
> Nome is the file name i have also try whit your syntax but nothing is
> change.
>
> Regards
>
> Luca
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users@...
To unsubscribe from this group, send email to cherrypy-users-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---

LightInTheBox - Buy quality products at wholesale price