XML-RPC MetaWeblog newMediaObject overwrite problem
-
Hello,
I am trying to use newMediaObject function to upload a file using Java. In general, this is how my code looks:
XmlRpcClient client = getClient(); Map<Object, Object> fileData = new HashMap<Object, Object>(); fileData.put("name", fileName); fileData.put("type", type); fileData.put("bits", fileBytes); fileData.put("overwrite", Boolean.TRUE); Object[] params = new Object[]{new Integer(0), username, password, fileData}; Object uploadResult = client.execute("metaWeblog.newMediaObject", params);
Everything works well but one thing. The file gets uploaded and it looks good but the problem is that the “overwrite” part seems to be not working. Any time I run this code, a new file gets uploaded, even though I am always using the same file name. A number gets appended to the file name.
Also, “wpid-” is prepended to the file name for some reason. So if my file name is “image.png”, after executing this, the WordPress has an image uploaded with a name “wpid-image.png”. If I run it again, I get “wpid-image1.png”.
When I set “overwrite” to Boolean.FALSE, it obviously still does not overwrite but this time nothing gets prepended to the file name, so I have “image.png”.
Please let me know if I am doing something incorrect in my code and also please let me know how would an example code look when I want the uploaded file to overwrite the existing file.
- The topic ‘XML-RPC MetaWeblog newMediaObject overwrite problem’ is closed to new replies.