public FormDataContentDisposition(HttpHeaderReader reader, boolean fileNameFix) throws ParseException { super(reader, fileNameFix); if (!"form-data".equalsIgnoreCase(getType())) { throw new IllegalArgumentException("The content disposition type is not equal to form-data"); } name = getParameters().get("name"); if (name == null) { throw new IllegalArgumentException("The name parameter is not present"); } }
/** * Constructor for the builder. * * @param type the disposition type. will be "form-data". * @param name the control name. * @param fileName the file name. * @param creationDate the creation date. * @param modificationDate the modification date. * @param readDate the read date. * @param size the size. * @throws IllegalArgumentException if the type is not equal to "form-data" * or the name is {@code null} */ protected FormDataContentDisposition(String type, String name, String fileName, Date creationDate, Date modificationDate, Date readDate, long size) { super(type, fileName, creationDate, modificationDate, readDate, size); this.name = name; if (!"form-data".equalsIgnoreCase(getType())) { throw new IllegalArgumentException("The content disposition type is not equal to form-data"); } if (name == null) { throw new IllegalArgumentException("The name parameter is not present"); } }
public FormDataContentDisposition(HttpHeaderReader reader, boolean fileNameFix) throws ParseException { super(reader, fileNameFix); if (!"form-data".equalsIgnoreCase(getType())) { throw new IllegalArgumentException("The content disposition type is not equal to form-data"); } name = getParameters().get("name"); if (name == null) { throw new IllegalArgumentException("The name parameter is not present"); } }
public FormDataContentDisposition(HttpHeaderReader reader, boolean fileNameFix) throws ParseException { super(reader, fileNameFix); if (!"form-data".equalsIgnoreCase(getType())) { throw new IllegalArgumentException("The content disposition type is not equal to form-data"); } name = getParameters().get("name"); if (name == null) { throw new IllegalArgumentException("The name parameter is not present"); } }
public FormDataContentDisposition(HttpHeaderReader reader, boolean fileNameFix) throws ParseException { super(reader, fileNameFix); if (!"form-data".equalsIgnoreCase(getType())) { throw new IllegalArgumentException("The content disposition type is not equal to form-data"); } name = getParameters().get("name"); if (name == null) { throw new IllegalArgumentException("The name parameter is not present"); } }
public FormDataContentDisposition(HttpHeaderReader reader, boolean fileNameFix) throws ParseException { super(reader, fileNameFix); if (!"form-data".equalsIgnoreCase(getType())) { throw new IllegalArgumentException("The content disposition type is not equal to form-data"); } name = getParameters().get("name"); if (name == null) { throw new IllegalArgumentException("The name parameter is not present"); } }
/** * Constructor for the builder. * * @param type the disposition type. will be "form-data". * @param name the control name. * @param fileName the file name. * @param creationDate the creation date. * @param modificationDate the modification date. * @param readDate the read date. * @param size the size. * @throws IllegalArgumentException if the type is not equal to "form-data" * or the name is {@code null} */ protected FormDataContentDisposition(String type, String name, String fileName, Date creationDate, Date modificationDate, Date readDate, long size) { super(type, fileName, creationDate, modificationDate, readDate, size); this.name = name; if (!"form-data".equalsIgnoreCase(getType())) { throw new IllegalArgumentException("The content disposition type is not equal to form-data"); } if (name == null) { throw new IllegalArgumentException("The name parameter is not present"); } }
/** * Constructor for the builder. * * @param type the disposition type. will be "form-data". * @param name the control name. * @param fileName the file name. * @param creationDate the creation date. * @param modificationDate the modification date. * @param readDate the read date. * @param size the size. * @throws IllegalArgumentException if the type is not equal to "form-data" * or the name is {@code null} */ protected FormDataContentDisposition(String type, String name, String fileName, Date creationDate, Date modificationDate, Date readDate, long size) { super(type, fileName, creationDate, modificationDate, readDate, size); this.name = name; if (!"form-data".equalsIgnoreCase(getType())) { throw new IllegalArgumentException("The content disposition type is not equal to form-data"); } if (name == null) { throw new IllegalArgumentException("The name parameter is not present"); } }
/** * Constructor for the builder. * * @param type the disposition type. will be "form-data". * @param name the control name. * @param fileName the file name. * @param creationDate the creation date. * @param modificationDate the modification date. * @param readDate the read date. * @param size the size. * @throws IllegalArgumentException if the type is not equal to "form-data" * or the name is {@code null} */ protected FormDataContentDisposition(String type, String name, String fileName, Date creationDate, Date modificationDate, Date readDate, long size) { super(type, fileName, creationDate, modificationDate, readDate, size); this.name = name; if (!"form-data".equalsIgnoreCase(getType())) { throw new IllegalArgumentException("The content disposition type is not equal to form-data"); } if (name == null) { throw new IllegalArgumentException("The name parameter is not present"); } }
/** * Constructor for the builder. * * @param type the disposition type. will be "form-data". * @param name the control name. * @param fileName the file name. * @param creationDate the creation date. * @param modificationDate the modification date. * @param readDate the read date. * @param size the size. * @throws IllegalArgumentException if the type is not equal to "form-data" * or the name is {@code null} */ protected FormDataContentDisposition(String type, String name, String fileName, Date creationDate, Date modificationDate, Date readDate, long size) { super(type, fileName, creationDate, modificationDate, readDate, size); this.name = name; if (!"form-data".equalsIgnoreCase(getType())) { throw new IllegalArgumentException("The content disposition type is not equal to form-data"); } if (name == null) { throw new IllegalArgumentException("The name parameter is not present"); } }
@Consumes(MediaType.MULTIPART_FORM_DATA) @POST public void upload(@FormDataParam("file") final InputStream rdfInputStream, @FormDataParam("file") final FormDataContentDisposition disposition, @FormDataParam("VRE_ID") String vreNameInput) { final String vreName = vreNameInput != null && vreNameInput.length() > 0 ? vreNameInput : "RdfImport"; transactionEnforcer.execute(timbuctooActions -> { timbuctooActions.rdfCleanImportSession(vreName, session -> { final RdfImporter rdfImporter = new RdfImporter(graphWrapper, vreName, vres, session); rdfImporter.importRdf(rdfInputStream, disposition.getType()); return commit(); }); return commit(); }); }
@POST @Consumes(MediaType.MULTIPART_FORM_DATA) public void upload(FormDataMultiPart formParams){ Map<String, List<FormDataBodyPart>> fieldsByName = formParams.getFields(); for (List<FormDataBodyPart> fields : fieldsByName.values()) { for (FormDataBodyPart field : fields){ // Check if fields are files(If any one knows better solution to check files[] please share your answers) if (StringUtils.equals("files", StringUtils.substringBefore(field.getName(), "["))) { //To read file content InputStream is = field.getEntityAs(InputStream.class); String fileName = field.getName(); field.getMediaType();//File mimeType //To get file details like size,file name,etc FormDataContentDisposition f=field.getFormDataContentDisposition(); System.out.println(f.getFileName()); Note: f.getType() not return the actual file type it returns mime type as form-data to get actual mime type use FormDataBodyPart media type like above. } get other form data like user name else if(StringUtils.equals(field.getName(),"userName")){ System.out.println(field.getValue()); } } } }