-
Type: Bug
-
Status: Resolved
-
Priority: Minor
-
Resolution: Fixed
-
Affects Version/s: 5.8
-
Fix Version/s: 5.8.0-HF01, 5.9.1
-
Component/s: Automation
When using Automation to upload a Blob using a MultiPart requests, the filename and mimetype can be missing.
Typically, this works correctly only with FileBlob.
The current code does
protected void setBlob(Blob blob, String id) throws Exception { MimeBodyPart part = new MimeBodyPart(); if (blob instanceof HasFile) { part.attachFile(((HasFile) blob).getFile()); } else { part.setDataHandler(new DataHandler(new BlobDataSource(blob))); // XXX missing part.setFileName(blob.getFileName()); } part.setHeader("Content-Type", blob.getMimeType()); part.setHeader("Content-Transfer-Encoding", "binary"); int length = blob.getLength(); if (length > -1) { part.setHeader("Content-Length", Integer.toString(length)); } part.setContentID(id); mp.addBodyPart(part); }
Since only FileBlob does implement the HasFile interface, only FileBlob will generate a MultiPart request with the correct FileName.