Need Help in downloading a file from server

67 views
Skip to first unread message

ravi

unread,
Jul 13, 2012, 7:55:18 AM7/13/12
to pylons-...@googlegroups.com
Hi,

I am trying to download a file from server like this

response.headers['Content-Type'] =  'text/csv'

response.headers['Content-disposition'] = 'attachment; filename=suggest.csv'

fapp = FileApp(<Full File Path>)

return fapp(request.environ, self.start_response)

But i am getting trying to download a file from server like this 


"Method Not Allowed


The method POST is not allowed for this resource.\r\nYou cannot POST a file

WSGI Server"

Please help me 

Thanks

Craig Younkins

unread,
Jul 13, 2012, 10:28:51 AM7/13/12
to pylons-...@googlegroups.com
It looks more like you are sending a POST request to download a file. POST is for requests that modify server state. Use GET since downloading a file does not.

Craig Younkins



--
You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
To view this discussion on the web visit https://groups.google.com/d/msg/pylons-discuss/-/66EIzPurnP4J.
To post to this group, send email to pylons-...@googlegroups.com.
To unsubscribe from this group, send email to pylons-discus...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.

ravi

unread,
Jul 16, 2012, 10:38:05 PM7/16/12
to pylons-...@googlegroups.com
Hi Craig,

Thanks for the reply. I can not use GET method as i want to pass huge data to the server. 

Right now what i am doing is first sending the POST request and getting response as file path. next sending a GET request in success callback function to get the data.

But here the problem i am facing is csv file ouput is not in correct format. all rows data coming in single line. 

Could you please suggest me in this issue

Thanks & Regards,
Ravi Kumar

Jonathan Vanasco

unread,
Jul 17, 2012, 12:13:51 PM7/17/12
to pylons-discuss


On Jul 16, 10:38 pm, ravi <4uall.raviku...@gmail.com> wrote:
> But here the problem i am facing is csv file ouput is not in correct
> format. all rows data coming in single line.

That could be a text encoding issue. The single line could be - for
example , but my guess - because you are on a Windows machine but
instead of creating \r\n newlines, your app is just creating \n . You
also could not be escaping the newlines correctly -- i noticed your
error has the characters '\r\n'.

Newline in different operating systems:
\r\n = Windows
\n = Unix
\r = Mac

Read this page:

http://forums.codeguru.com/showthread.php?253826-C-String-What-is-the-difference-between-%5Cn-and-%5Cr%5Cn

Reply all
Reply to author
Forward
0 new messages