maxcutler / python-wordpress-xmlrpc

Python library for WordPress XML-RPC integration

Home Page:http://python-wordpress-xmlrpc.rtfd.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

upload media change the file name itself

viponedream opened this issue · comments

filepath = 'D:\APP_MY\TOOLS_MY\crawler\vars\download\wp-content/uploads/2020/07\graffiti1-c1063fa88b70424e95fe0bec6a222674-kaips.com.jpg'

def upload(self, filepath): filename = os.path.split(filepath)[-1] # prepare metadata data = { 'name': filename, 'type': mimetypes.guess_type(filepath)[0], # mimetype } # read the binary file and let the XMLRPC library encode it into base64 with open(filepath, 'rb') as img: data['bits'] = xmlrpc_client.Binary(img.read()) response = self.client.call(media.UploadFile(data)) # print (response) return response

it upload well, but the file name has changed.
the source file name is : graffiti1-c1063fa88b70424e95fe0bec6a222674-kaips.com.jpg
it changed to be: 'graffiti1-c1063fa88b70424e95fe0bec6a222674-kaips.com_.jpg'
it added _ at last , why?
How can i use my own filename?