static String getDisposition(MimePart part) throws MessagingException { String s = part.getHeader("Content-Disposition", null); if (s == null) return null; ContentDisposition cd = new ContentDisposition(s); return cd.getDisposition(); }
static String getDisposition(MimePart part) throws MessagingException { String s = part.getHeader("Content-Disposition", null); if (s == null) return null; ContentDisposition cd = new ContentDisposition(s); return cd.getDisposition(); }
static void setDisposition(MimePart part, String disposition) throws MessagingException { if (disposition == null) part.removeHeader("Content-Disposition"); else { String s = part.getHeader("Content-Disposition", null); if (s != null) { /* A Content-Disposition header already exists .. * * Override disposition, but attempt to retain * existing disposition parameters */ ContentDisposition cd = new ContentDisposition(s); cd.setDisposition(disposition); disposition = cd.toString(); } part.setHeader("Content-Disposition", disposition); } }
static void setDisposition(MimePart part, String disposition) throws MessagingException { if (disposition == null) part.removeHeader("Content-Disposition"); else { String s = part.getHeader("Content-Disposition", null); if (s != null) { /* A Content-Disposition header already exists .. * * Override disposition, but attempt to retain * existing disposition parameters */ ContentDisposition cd = new ContentDisposition(s); cd.setDisposition(disposition); disposition = cd.toString(); } part.setHeader("Content-Disposition", disposition); } }
static String getFileName(MimePart part) throws MessagingException { String filename = null; String s = part.getHeader("Content-Disposition", null); if (s != null) { // Parse the header .. ContentDisposition cd = new ContentDisposition(s); filename = cd.getParameter("filename"); } if (filename == null) { // Still no filename ? Try the "name" ContentType parameter s = part.getHeader("Content-Type", null); s = MimeUtil.cleanContentType(part, s); if (s != null) { try { ContentType ct = new ContentType(s); filename = ct.getParameter("name"); } catch (ParseException pex) { } // ignore it } } if (decodeFileName && filename != null) { try { filename = MimeUtility.decodeText(filename); } catch (UnsupportedEncodingException ex) { throw new MessagingException("Can't decode filename", ex); } } return filename; }
static String getFileName(MimePart part) throws MessagingException { String filename = null; String s = part.getHeader("Content-Disposition", null); if (s != null) { // Parse the header .. ContentDisposition cd = new ContentDisposition(s); filename = cd.getParameter("filename"); } if (filename == null) { // Still no filename ? Try the "name" ContentType parameter s = part.getHeader("Content-Type", null); s = MimeUtil.cleanContentType(part, s); if (s != null) { try { ContentType ct = new ContentType(s); filename = ct.getParameter("name"); } catch (ParseException pex) { } // ignore it } } if (decodeFileName && filename != null) { try { filename = MimeUtility.decodeText(filename); } catch (UnsupportedEncodingException ex) { throw new MessagingException("Can't decode filename", ex); } } return filename; }
WebClient client = WebClient.create("http://books"); client.type("multipart/form-data"); ContentDisposition cd = new ContentDisposition("attachment;filename=image.jpg"); Attachment att = new Attachment("root", imageInputStream, cd); client.post(new MultipartBody(att)); // or just post the attachment if it's a single part request only client.post(att); // or just use a file client.post(getClass().getResource("image.png").getFile());
List<Attachment> atts = new LinkedList<Attachment>(); ContentDisposition cd = new ContentDisposition("form-data; name=\"file\";filename=\"test.txt\""); atts.add(new Attachment("file", new ByteArrayInputStream("testContent".getBytes()),cd)); ContentDisposition cd1 = new ContentDisposition("form-data; name=\"param1\";"); atts.add(new Attachment("param1",new ByteArrayInputStream("paramValue".getBytes()),cd1)); ContentDisposition cd2 = new ContentDisposition("form-data; name=\"param2\";"); atts.add(new Attachment("param2",new ByteArrayInputStream("value".getBytes()),cd1)); MultipartBody body = new MultipartBody(atts); Response response= client.post(body);
InputStream inputStream = getClass().getResourceAsStream("/file/message.jsp"); WebClient client = WebClient.create("http://myURL"); client.type("multipart/form-data"); ContentDisposition cd = new ContentDisposition("attachment;filename=message.jsp"); Attachment att = new Attachment("root", inputStream, cd); client.post(new MultipartBody(att));
static String getDisposition(MimePart part) throws MessagingException { String s = part.getHeader("Content-Disposition", null); if (s == null) return null; ContentDisposition cd = new ContentDisposition(s); return cd.getDisposition(); }
static String getDisposition(MimePart part) throws MessagingException { String s = part.getHeader("Content-Disposition", null); if (s == null) return null; ContentDisposition cd = new ContentDisposition(s); return cd.getDisposition(); }
static String getDisposition(MimePart part) throws MessagingException { String s = part.getHeader("Content-Disposition", null); if (s == null) return null; ContentDisposition cd = new ContentDisposition(s); return cd.getDisposition(); }
static String getDisposition(MimePart part) throws MessagingException { String s = part.getHeader("Content-Disposition", null); if (s == null) return null; ContentDisposition cd = new ContentDisposition(s); return cd.getDisposition(); }
static String getDisposition(MimePart part) throws MessagingException { String s = part.getHeader("Content-Disposition", null); if (s == null) return null; ContentDisposition cd = new ContentDisposition(s); return cd.getDisposition(); }
static String getDisposition(MimePart part) throws MessagingException { String s = part.getHeader("Content-Disposition", null); if (s == null) return null; ContentDisposition cd = new ContentDisposition(s); return cd.getDisposition(); }
static String getDisposition(MimePart part) throws MessagingException { String s = part.getHeader("Content-Disposition", null); if (s == null) return null; ContentDisposition cd = new ContentDisposition(s); return cd.getDisposition(); }
if (s != null) { ContentDisposition cd = new ContentDisposition(s); String filename = cd.getParameter("filename"); if (filename != null) {
if (s != null) { ContentDisposition cd = new ContentDisposition(s); String filename = cd.getParameter("filename"); if (filename != null) {
new ContentDisposition(s == null ? Part.ATTACHMENT : s);
new ContentDisposition(s == null ? Part.ATTACHMENT : s);