marekrei / smuploader

Upload / download library for SmugMug.com
11 stars 10 forks source link

rauth will error on uploading image #10

Open bobgott opened 3 years ago

bobgott commented 3 years ago

Using your smugmug.py I can successfully retrieve albums, images and create new nodes as well.

However, when trying to do a simple image upload via _uploadimage(), I get the following error:

  File "C:\....\lib\site-packages\rauth\session.py", line 228, in _parse_optional_params
    if oauth_param in data:
TypeError: a bytes-like object is required, not 'str'

The offending line is: if oauth_param in data: ....

where oauth_param is a list of strings, and data is binary. This seems like an rauth bug .. but I'm sure you had this code working at one time. I tried uploading an image with the 'files' parameter but SmugMug kept giving me a file corruption error (maybe my error).

Not sure if you still support this project but hopefully there is a clear/easy answer.

(Windows 10, python 3.7.2)

marekrei commented 3 years ago

This is an issue I haven't been able to solve either. It works with python2, but not any more with python3. I had another go at tracking down the problem, but it does seem like it's an issue on rauth side. There's a statement in there that looks for a key in the uploaded data, which in this case is a image. I guess python2 quietly returned false in such a scenario, but python3 throws a TypeError.

I'll post on the rauth board to see if anyone has a suggestion for how to handle this.

bobgott commented 3 years ago

Well, it appears nobody is home at rauth. There hasn't been an update in 5 years and they don't seem to be responding (at least publicly) to issues. I just saw your posting OAuth1Session image data throws error with python3 #209,

I have a sneaky feeling that rauth will have to be replaced .. but I'll keep my hopes up for awhile.

bobgott commented 3 years ago

As a side note, it appears that using requests-oauthlib seems to be a pretty straight forward plug-in for your smugmug.py.

from requests_oauthlib import OAuth1Session
self.smugmug_session = OAuth1Session(
                client_key=self.consumer_key,
                client_secret=self.consumer_secret,
                resource_owner_key=self.access_token,
                resource_owner_secret=self.access_token_secret
            )

Have not tested a bunch .. but at least this repository is kept up to date.