Используя пример, найденный в https://python-wordpress-xmlrpc.readthedocs.io/en/latest/examples/media.html#uploading -a-file
, я могу загрузить изображение на носитель Wordpress. Можно ли загрузить MP3?
Пример можно найти ниже:
from wordpress_xmlrpc import Client, WordPressPost
from wordpress_xmlrpc.compat import xmlrpc_client
from wordpress_xmlrpc.methods import media, posts
client = Client(...)
filename = '/path/to/my/picture.jpg'
data = {
'name': 'picture.jpg',
'type': 'image/jpeg', # mimetype
}
with open(filename, 'rb') as img:
data['bits'] = xmlrpc_client.Binary(img.read())
response = client.call(media.UploadFile(data))
attachment_id = response['id']