Skip to content
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

TypeError: expected str, bytes or os.PathLike object, not BufferedReader #169

Open
Phantom-Cass opened this issue Jun 24, 2023 · 1 comment

Comments

@Phantom-Cass
Copy link

Phantom-Cass commented Jun 24, 2023

Not a bug, just an error I can't find a fix for

import pytumblr
import os

Authenticate via Tumblr API

client = pytumblr.TumblrRestClient(
"client key",
'client secret',
'0auth key',
'0auth secret',
)

Set the directory containing the photos to upload

photo_directory = 'folder/to/photos'

Iterate through the files in the directory

for filename in os.listdir(photo_directory):
if filename.endswith('.JPG'):
# Upload the photo to Tumblr
photo = open(photo_directory +"/"+ filename, 'rb')
response = client.create_photo('blog url', data=photo, tags=['photo dump'])
photo.close()
print("Did it.")

@dj-ratty
Copy link
Contributor

pytumblr can open file for you as in ReadMe

Just pass the filename instead of opening like client.create_photo('blog url', data=filename, tags=['photo', 'dump'])

Also, please use MarkDown properly next time: https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks

Don't forget to read the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants