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

upload media change the file name itself #139

Open
viponedream opened this issue Jul 11, 2020 · 0 comments
Open

upload media change the file name itself #139

viponedream opened this issue Jul 11, 2020 · 0 comments

Comments

@viponedream
Copy link

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?

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

1 participant