Open JonhNathan987456 opened 7 years ago
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.
Hi @droustchev do you think you can help us?
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.
@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
@happyraul any news?
I'll block some time next week to work on this library.
Hi! Can you give me some example for create media, please ? I try but not success :(.