Upload image kivy url request

372 views
Skip to first unread message

Gilberto

unread,
Jul 21, 2021, 1:44:15 PM7/21/21
to Kivy users support
I m new here,
Some time ago I worked with kivy now I have a problem with, here is my problem I must upload an images with description in the server, I use django as backend and I use kivy urlrequest, how can I do this, Thank you all

Gilberto manohisoa

unread,
Jul 22, 2021, 8:59:22 AM7/22/21
to kivy-...@googlegroups.com
Please help me 
how to do that with kivy urlrequest, simple string or int I already know how to do it, but with the image I tried but either the server returns me bad request or kivy returns me the error message

Le mer. 21 juil. 2021 à 19:44, Gilberto <erwan.g...@gmail.com> a écrit :
I m new here,
Some time ago I worked with kivy now I have a problem with, here is my problem I must upload an images with description in the server, I use django as backend and I use kivy urlrequest, how can I do this, Thank you all

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/179c886d-fdd7-492e-80f3-422ebb1bfde8n%40googlegroups.com.

Robert

unread,
Jul 22, 2021, 1:00:45 PM7/22/21
to Kivy users support
A response is more likely if a very specific question is asked, code fragments are usually required possibly supported by a very small run-able example, and definitely showing any error messages.

I don't use Kivy's urlrequest, I use requests (it handles headers, there is excellent documentation and lots of users) and in a thread. I don't have an example of your case.

Gilberto manohisoa

unread,
Jul 22, 2021, 2:20:54 PM7/22/21
to kivy-...@googlegroups.com
Thank you for your answer,

I'm sorry for my rude, I use kivy urlrequest because it is ansync, I post a piece of my code:

def creat_profile(self, *args):
username = self.screen.get_screen('login_screen').ids.username.text
mail = self.screen.get_screen('signin_screen').ids.mail.text
avatar = self.path
if email != '':
params = json.dumps({'username': username, 'email': mail})
headers = {'Content-type': 'multipart/form-data',
'Accept': 'application/json'}
req = UrlRequest('http://127.0.0.1:8000/user_profile', method='POST', on_success=self.profil_created, on_failure=self.profil_error, req_body=params,
req_headers=headers, ca_file=cfi.where(),verify=True, on_error=self.error, files = avatar)

Elliot Garbus

unread,
Jul 22, 2021, 7:02:35 PM7/22/21
to kivy-...@googlegroups.com
UrlRequest('http://127.0.0.1:8000/user_profile', method='POST', on_success=self.profil_created, 
           on_failure=self.profil_error, req_body=params, req_headers=headers, ca_file=cfi.where(),
           verify=True, on_error=self.error, files = avatar)

 

Just looking at this code, the files keyword is not in the documentation.

I don’t see where you are opening the file or passing the file handle in the call.

 

I would recommend searching the web for how the requests (the requests library) is used for posting an image, and modify that for UrlRequest.

Robert

unread,
Jul 22, 2021, 10:38:07 PM7/22/21
to Kivy users support
A quick search here and you will find an example , search for      127.0.0

Gilberto manohisoa

unread,
Jul 23, 2021, 3:15:33 AM7/23/21
to kivy-...@googlegroups.com
hello, I know that in the documentation does not have "files" that is why I ask the question how to do that?
Thank you

Reply all
Reply to author
Forward
0 new messages