public void write(Path target) throws IOException { if (file != null) { try { Files.move(file, target); return; } catch (IOException e) { // ignore and let the Files.copy, outside // this if block, take over and attempt to copy it } } try (InputStream is = getInputStream()) { Files.copy(is, target); } } }
public long getFileSize() throws IOException { if (isInMemory()) { return content.length; } else { return Files.size(file); } }
final Path path = formData.getFirst(fileField).getFileItem().getFile();
public void write(Path target) throws IOException { if (file != null) { try { Files.move(file, target); return; } catch (IOException e) { // ignore and let the Files.copy, outside // this if block, take over and attempt to copy it } } try (InputStream is = getInputStream()) { Files.copy(is, target); } } }
@Override public boolean isFile() { return fileItem != null && !fileItem.isInMemory(); }
public static java.util.Optional<Path> filePath(final HttpServerExchange exchange, final String name) { return java.util.Optional.ofNullable(exchange.getAttachment(FormDataParser.FORM_DATA).get(name)).map(Deque::getFirst).map( fv -> fv.getFileItem().getFile()); }
public static File file(final HttpServerExchange exchange, final String name) throws java.lang.IllegalArgumentException { try { return exchange.getAttachment(FormDataParser.FORM_DATA).get(name).getFirst().getFileItem().getFile().toFile(); } catch(NullPointerException e) { throw new IllegalArgumentException("Missing parameter " + name, e); } }
@Override public boolean isFile() { return fileItem != null && !fileItem.isInMemory(); }
public long getFileSize() throws IOException { if (isInMemory()) { return content.length; } else { return Files.size(file); } }
public static java.util.Optional<File> file(final HttpServerExchange exchange, final String name) { return java.util.Optional.ofNullable(exchange.getAttachment(FormDataParser.FORM_DATA).get(name)).map(Deque::getFirst).map( fv -> fv.getFileItem().getFile().toFile()); }
FormValueImpl(byte[] data, String fileName, HeaderMap headers) { this.fileItem = new FileItem(data); this.fileName = fileName; this.headers = headers; this.value = null; }
FormValueImpl(Path file, final String fileName, HeaderMap headers) { this.fileItem = new FileItem(file); this.headers = headers; this.fileName = fileName; this.value = null; }
public static Path filePath(final HttpServerExchange exchange, final String name) throws java.lang.IllegalArgumentException { try { return exchange.getAttachment(FormDataParser.FORM_DATA).get(name).getFirst().getFileItem().getFile(); } catch(NullPointerException e) { throw new IllegalArgumentException("Missing parameter " + name, e); } }
@Override public Path getPath() { if (fileItem == null) { throw UndertowMessages.MESSAGES.formValueIsAString(); } if (fileItem.isInMemory()) { throw UndertowMessages.MESSAGES.formValueIsInMemoryFile(); } return fileItem.getFile(); }
@Override public void delete() throws IOException { if (formValue.isFileItem()) { try { formValue.getFileItem().delete(); } catch (IOException e) { throw UndertowServletMessages.MESSAGES.deleteFailed(formValue.getPath()); } } }
@Override public InputStream getInputStream() throws IOException { if (formValue.isFileItem()) { return formValue.getFileItem().getInputStream(); } else { String requestedCharset = servletRequest.getCharacterEncoding(); String charset = requestedCharset != null ? requestedCharset : servletContext.getDeployment().getDefaultRequestCharset().name(); return new ByteArrayInputStream(formValue.getValue().getBytes(charset)); } }
public void write(Path target) throws IOException { if (file != null) { try { Files.move(file, target); } catch (IOException e) { Files.copy(getInputStream(), target); } } else { Files.copy(getInputStream(), target); } } }
FormValueImpl(Path file, final String fileName, HeaderMap headers) { this.fileItem = new FileItem(file); this.headers = headers; this.fileName = fileName; this.value = null; }
public long getFileSize() throws IOException { if (isInMemory()) { return content.length; } else { return Files.size(file); } }
FormValueImpl(byte[] data, String fileName, HeaderMap headers) { this.fileItem = new FileItem(data); this.fileName = fileName; this.headers = headers; this.value = null; }