GithubHelp home page GithubHelp logo

Error with put_photo - UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 413: ordinal not in range(128) about facebook-sdk HOT 12 CLOSED

mobolic avatar mobolic commented on July 18, 2024
Error with put_photo - UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 413: ordinal not in range(128)

from facebook-sdk.

Comments (12)

sontek avatar sontek commented on July 18, 2024

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'

from facebook-sdk.

martey avatar martey commented on July 18, 2024

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?

from facebook-sdk.

sontek avatar sontek commented on July 18, 2024

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:
http://studiosnaps.com/upload_26.jpg

from facebook-sdk.

sontek avatar sontek commented on July 18, 2024

If it helps, this was uploading a photo to a page's album, not a personal album.

from facebook-sdk.

martey avatar martey commented on July 18, 2024

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?

from facebook-sdk.

sontek avatar sontek commented on July 18, 2024

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.

from facebook-sdk.

martey avatar martey commented on July 18, 2024

One of the computers I tested on is running python 2.7.3rc2. Since the error you are receiving is a UnicodeDecodeError, it has nothing to do with the type of Facebook profile you are trying to upload the photo to.

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)?

from facebook-sdk.

martey avatar martey commented on July 18, 2024

@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.

from facebook-sdk.

honi avatar honi commented on July 18, 2024

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?

from facebook-sdk.

honi avatar honi commented on July 18, 2024

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?

from facebook-sdk.

martey avatar martey commented on July 18, 2024

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:

*GIF *JPG *PNG *PSD *TIFF *JP2 *IFF *WBMP *XBM

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).

from facebook-sdk.

honi avatar honi commented on July 18, 2024

Created 2 issues. Posting here for reference:
UnicodeDecodeError: #43
Hardcoded JPG format: #44

from facebook-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.