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

Example for create media #14

Open
JonhNathan987456 opened this issue Mar 5, 2017 · 7 comments
Open

Example for create media #14

JonhNathan987456 opened this issue Mar 5, 2017 · 7 comments

Comments

@JonhNathan987456
Copy link

Hi!
Can you give me some example for create media, please ?
I try but not success :(.

@AjayAjaal
Copy link

I've been struggling with the same; I've managed to get the filename to show up in the wordpress media library but there is no data stored with it.

wp.create_media(headers={'Content-Disposition': 'attachment; filename="1037659601.jpg'}, data=open(filePathToImage).read().encode('base64'))

Any help from the creators would be nice.

@AjayAjaal
Copy link

Hi @droustchev do you think you can help us?

@happyraul
Copy link

Hi @AjayAjaal @JonhNathan987456,

Thanks for your feedback. Unfortunately I'm not able to provide support for these issues at the moment. I'm not sure if @droustchev would have time either.

At the time that we wrote this wrapper, the JSON API was a plugin for Wordpress, and we only supported Basic Auth for authentication. Since version 4.7, the plugin was added to core Wordpress, and I don't think Basic Auth works any more. I believe we need to update this lib to work for 4.7, and for that I would need to also support a different form of authentication.

In short, I'm not sure it makes sense for us to troubleshoot these issues until that underlying problem is fixed, which may take some time.

@droustchev
Copy link

droustchev commented Apr 10, 2017

@AjayAjaal, I tried uploading a file via curl, but have the same issue as you. I wasn't able to figure out how the WP API expects file uploads. If you can provide a curl command that works or a link to some documentation from WP, I can see what needs to be changed in the wrapper. Here is what I tried:

curl -v -u {WP_USER}:{WP_PASSWORD} \
-H "Content-Disposition: attachment; filename=test.jpg" \
-d {BASE64_ENCODED_FILE} \
-X POST http://{WP_HOST}/wp-json/wp/v2/media

@zodman
Copy link

zodman commented Jun 5, 2017

#17 can help you!

@mahnunchik
Copy link

@happyraul any news?

@happyraul
Copy link

I'll block some time next week to work on this library.

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

6 participants