Hello,
I'm using abdera to upload the new version of existing file.For example,
the existing file is testFile.doc, I would like to upload
newTestFile.pdf
File file = new File("link to newTestFile.pdf");
Part[] parts = {new StringPart("changeSummary", "summary"),
new StringPart("label", name),
new FilePart("file", "newTestFile.pdf", file,
"application/pdf", null)};
MultipartRequestEntity mre = new MultipartRequestEntity(parts,
provider.abderaClient.getHttpClientParams());
RequestOptions ro = provider.abderaClient.getDefaultRequestOptions();
ro.setHeader("X-HTTP-Method-Override", "PUT");
ro.setHeader("X-Update-Nonce", NONCEKEY);
ClientResponse cr = provider.abderaClient.post(URL_TO_UPLOAD, mre, ro);
With these code above, the content of newTestFile.pdf uploaded, but the
mimeType is always "application/msword"
If I use httpclient API to do the same thing
PostMethod postMethod = new PostMethod(URL_TO_UPLOAD);
File file = new File("link to newTestFile.pdf");Part[] parts = {new
StringPart("changeSummary", "summary"),
new StringPart("label", name),
new FilePart("file", "newTestFile.pdf", file,
"application/pdf", null)};
MultipartRequestEntity(parts, httpClient.getParams());
postMethod.addRequestHeader("X-HTTP-Method-Override", "PUT");
postMethod.addRequestHeader("X-Update-Nonce", noonce);
postMethod.setRequestEntity(mre);
httpClient.executeMethod(this.hostConfig, postMethod);
These code will upload the new content file of newTestFile.pdf, also it
changes the mimeType to "application/pdf".
Anyone can help me?
Thanks