-
Notifications
You must be signed in to change notification settings - Fork 952
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error with put_photo - UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 413: ordinal not in range(128) #33
Comments
req.data at line 190 has this fnky this_is_the_boundary stuff in it: \x14P\x01E\x14P\x01E\x14P\x01E\x14P\x01E\x14P\x01E\x14P\x07\xff\xd9\r\n------------ThIs_Is_tHe_bouNdaRY_$\r\nContent-Disposition: form-data; name="message"\r\n\r\nhi\r\n------------ThIs_Is_tHe_bouNdaRY_$--\r\n' |
Do you still get this error if you open the file in binary mode? If so, would it be possible for you to provide me with the image that is causing the error? |
According to the docs binary mode only matters on windows and I'm on Linux. It also says it could corrupt JPEG files. I did try it but got the same exception. Uploading the image does work with the facepy library that you can find here on github to compare how they are doing multipart forms. Here is the failing photo: |
If it helps, this was uploading a photo to a page's album, not a personal album. |
I tried to replicate this error using the image file you provided, but I have been unable to (the image uploaded successfully each time). Can you confirm that you are using the most recent version of this library? |
Yes, I was using the current version from master. I'm using python 2.7.3 on Ubuntu LTS 12.04. I was uploading to a fan/company page, not a personal profile page. |
One of the computers I tested on is running python 2.7.3rc2. Since the error you are receiving is a I tried more testing, but can still not replicate the error you are receiving. I noticed that your original traceback mentions gevent. Do you still get the error if you are not using it (i.e. using python on the command line)? |
@sontek, I have not heard anything from you on this, and there have been no additional reports of people with the same issue, so I am going to close this. |
I'm getting a UnicodeDecodeError while trying to upload a PIL generated PNG, stored in a django model. If I try to upload another file, it works fine. So I think it must be related with how I'm generating the image or something with PIL. I know I'm not providing much information, but do you have any ideas? |
Digging a bit more, I see that put_photo assumed the image is JPG: https://github.com/pythonforfacebook/facebook-sdk/blob/master/facebook.py#L261 Why is that? Facebook doesn't allow PNG? |
Some documentation from the old REST API I found suggests that the following file types are supported:
This is a bug in the library, but should be created as a new issue (since it is not the same issue as was originally reported). |
Traceback (most recent call last):
File "/home/sontek/.virtualenvs/studiosnaps/local/lib/python2.7/site-packages/gevent/greenlet.py", line 390, in run
result = self._run(_self.args, *_self.kwargs)
File "/home/sontek/.virtualenvs/studiosnaps/src/studiosnaps/booth/controller.py", line 114, in upload_photo
self.uploader.upload_photo(self.view.get_upload_file())
File "/home/sontek/.virtualenvs/studiosnaps/src/studiosnaps/booth/upload.py", line 283, in upload_photo
photo_response = fp_graph.put_photo(photo, '', album_id)
File "/home/sontek/.virtualenvs/studiosnaps/src/studiosnaps/booth/facebook.py", line 175, in put_photo
object_id = album_id or "me"
File "/usr/lib/python2.7/urllib2.py", line 126, in urlopen
return _opener.open(url, data, timeout)
File "/usr/lib/python2.7/urllib2.py", line 400, in open
response = self._open(req, data)
File "/usr/lib/python2.7/urllib2.py", line 418, in _open
'_open', req)
File "/usr/lib/python2.7/urllib2.py", line 378, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 1215, in https_open
return self.do_open(httplib.HTTPSConnection, req)
File "/usr/lib/python2.7/urllib2.py", line 1174, in do_open
h.request(req.get_method(), req.get_selector(), req.data, headers)
File "/usr/lib/python2.7/httplib.py", line 958, in request
self._send_request(method, url, body, headers)
File "/usr/lib/python2.7/httplib.py", line 992, in _send_request
self.endheaders(body)
File "/usr/lib/python2.7/httplib.py", line 954, in endheaders
self._send_output(message_body)
File "/usr/lib/python2.7/httplib.py", line 812, in _send_output
msg += message_body
UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 413: ordinal not in range(128)
I'm just calling:
The text was updated successfully, but these errors were encountered: