On 7/17/12, gavin lyons <renegade...@gmail.com> wrote:
> I have built the Django server as shown here
> http://stackoverflow.com/questions/5871730/need-a-minimal-django-file-upload-example
>
> I have been trying to build an android app that will allow me to select
> files on my phone and post them to the the server.  All the examples i am
> finding are for posting data to a php server which i have tried to adapt
> with little success.
>
> If anyone has an ideas how this can be achieved that would be greatly
> appreciated

It's hard to know what's actually not working from this description.
I'll guess that the APP is actually performing an HTTP request using
the POST method, targeting some specific URL.

You should be able to design a view to deal with whatever the APP is
posting.  But modern Django has CSRF protection by default, and I'll
bet the APP isn't dealing with that correctly.  There are two ways out
of this: 1. explicitly disable CSRF protection for the view in
question (there is a decorator for that); or 2. assuming that you have
the source code of the APP, you understand it, and you have a build
system on which to re-make it, you can modify the app to do a GET
first, have the response include the CSRF token, and return it
suitably (you probably have to deal with session and other cookies for
this).

I also presume that you require a log in in order to be allowed to
post to this django site.  Does the APP do that, and exchange the
corresponding cookies?

If the APP isn't doing simple HTTP, then, as the other gentleman
suggested, some purpose built API, like a REST scheme (tastypie,
djangorestframework, or the ;pmg om the tooth and apparently no longer
supported piston), or even SOAP (not for the faint of heart) would
make the APP useful with multiple disparate servers.

Bill

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

Reply via email to