@Override public Charset getCharset() { return fileUpload.getCharset(); }
private Optional<String> header(final String name) { if (name.equalsIgnoreCase("content-transfer-encoding")) { return Optional.of(data.getContentTransferEncoding()); } else if (name.equalsIgnoreCase("content-disposition")) { return Optional.of("form-data; name=\"" + data.getName() + "\"; filename=\"" + data.getFilename() + "\""); } else if (name.equalsIgnoreCase("content-type")) { String cs = Optional.ofNullable(data.getCharset()) .map(it -> "; charset=" + it.name()) .orElse(""); return Optional.ofNullable(data.getContentType()) .flatMap(it -> Optional.of(it + cs)); } else { return Optional.empty(); } }
@Override public void setContent(File file) throws IOException { checkSize(file.length()); if (file.length() > limitSize) { if (fileUpload instanceof MemoryFileUpload) { FileUpload memoryUpload = fileUpload; // change to Disk fileUpload = new DiskFileUpload(memoryUpload .getName(), memoryUpload.getFilename(), memoryUpload .getContentType(), memoryUpload .getContentTransferEncoding(), memoryUpload.getCharset(), definedSize); fileUpload.setMaxSize(maxSize); // release old upload memoryUpload.release(); } } fileUpload.setContent(file); }
@Override public void setContent(ByteBuf buffer) throws IOException { checkSize(buffer.readableBytes()); if (buffer.readableBytes() > limitSize) { if (fileUpload instanceof MemoryFileUpload) { FileUpload memoryUpload = fileUpload; // change to Disk fileUpload = new DiskFileUpload(memoryUpload .getName(), memoryUpload.getFilename(), memoryUpload .getContentType(), memoryUpload .getContentTransferEncoding(), memoryUpload.getCharset(), definedSize); fileUpload.setMaxSize(maxSize); // release old upload memoryUpload.release(); } } fileUpload.setContent(buffer); }
@Override public void addContent(ByteBuf buffer, boolean last) throws IOException { if (fileUpload instanceof MemoryFileUpload) { checkSize(fileUpload.length() + buffer.readableBytes()); if (fileUpload.length() + buffer.readableBytes() > limitSize) { DiskFileUpload diskFileUpload = new DiskFileUpload(fileUpload .getName(), fileUpload.getFilename(), fileUpload .getContentType(), fileUpload .getContentTransferEncoding(), fileUpload.getCharset(), definedSize); diskFileUpload.setMaxSize(maxSize); ByteBuf data = fileUpload.getByteBuf(); if (data != null && data.isReadable()) { diskFileUpload.addContent(data.retain(), false); } // release old upload fileUpload.release(); fileUpload = diskFileUpload; } } fileUpload.addContent(buffer, last); }
@Override public void setContent(InputStream inputStream) throws IOException { if (fileUpload instanceof MemoryFileUpload) { FileUpload memoryUpload = fileUpload; // change to Disk fileUpload = new DiskFileUpload(fileUpload .getName(), fileUpload.getFilename(), fileUpload .getContentType(), fileUpload .getContentTransferEncoding(), fileUpload.getCharset(), definedSize); fileUpload.setMaxSize(maxSize); // release old upload memoryUpload.release(); } fileUpload.setContent(inputStream); }
internal.addValue("\r\n" + HttpHeaderNames.CONTENT_TRANSFER_ENCODING + ": " + HttpPostBodyUtil.TransferEncodingMechanism.BINARY.value() + "\r\n\r\n"); } else if (fileUpload.getCharset() != null) { internal.addValue("; " + HttpHeaderValues.CHARSET + '=' + fileUpload.getCharset().name() + "\r\n\r\n"); } else { internal.addValue("\r\n\r\n");
@Override public Charset getCharset() { return fileUpload.getCharset(); }
@Override public Charset getCharset() { return fileUpload.getCharset(); }
@Override public Charset getCharset() { return fileUpload.getCharset(); }
@Override public Charset getCharset() { return fileUpload.getCharset(); }
private Optional<String> header(final String name) { if (name.equalsIgnoreCase("content-transfer-encoding")) { return Optional.of(data.getContentTransferEncoding()); } else if (name.equalsIgnoreCase("content-disposition")) { return Optional.of("form-data; name=\"" + data.getName() + "\"; filename=\"" + data.getFilename() + "\""); } else if (name.equalsIgnoreCase("content-type")) { String cs = Optional.ofNullable(data.getCharset()) .map(it -> "; charset=" + it.name()) .orElse(""); return Optional.ofNullable(data.getContentType()) .flatMap(it -> Optional.of(it + cs)); } else { return Optional.empty(); } }
@Override public void setContent(File file) throws IOException { checkSize(file.length()); if (file.length() > limitSize) { if (fileUpload instanceof MemoryFileUpload) { FileUpload memoryUpload = fileUpload; // change to Disk fileUpload = new DiskFileUpload(memoryUpload .getName(), memoryUpload.getFilename(), memoryUpload .getContentType(), memoryUpload .getContentTransferEncoding(), memoryUpload.getCharset(), definedSize); fileUpload.setMaxSize(maxSize); // release old upload memoryUpload.release(); } } fileUpload.setContent(file); }
@Override public void setContent(File file) throws IOException { checkSize(file.length()); if (file.length() > limitSize) { if (fileUpload instanceof MemoryFileUpload) { FileUpload memoryUpload = fileUpload; // change to Disk fileUpload = new DiskFileUpload(memoryUpload .getName(), memoryUpload.getFilename(), memoryUpload .getContentType(), memoryUpload .getContentTransferEncoding(), memoryUpload.getCharset(), definedSize); fileUpload.setMaxSize(maxSize); // release old upload memoryUpload.release(); } } fileUpload.setContent(file); }
@Override public void setContent(ByteBuf buffer) throws IOException { checkSize(buffer.readableBytes()); if (buffer.readableBytes() > limitSize) { if (fileUpload instanceof MemoryFileUpload) { FileUpload memoryUpload = fileUpload; // change to Disk fileUpload = new DiskFileUpload(memoryUpload .getName(), memoryUpload.getFilename(), memoryUpload .getContentType(), memoryUpload .getContentTransferEncoding(), memoryUpload.getCharset(), definedSize); fileUpload.setMaxSize(maxSize); // release old upload memoryUpload.release(); } } fileUpload.setContent(buffer); }
@Override public void addContent(ByteBuf buffer, boolean last) throws IOException { if (fileUpload instanceof MemoryFileUpload) { checkSize(fileUpload.length() + buffer.readableBytes()); if (fileUpload.length() + buffer.readableBytes() > limitSize) { DiskFileUpload diskFileUpload = new DiskFileUpload(fileUpload .getName(), fileUpload.getFilename(), fileUpload .getContentType(), fileUpload .getContentTransferEncoding(), fileUpload.getCharset(), definedSize); diskFileUpload.setMaxSize(maxSize); ByteBuf data = fileUpload.getByteBuf(); if (data != null && data.isReadable()) { diskFileUpload.addContent(data.retain(), false); } // release old upload fileUpload.release(); fileUpload = diskFileUpload; } } fileUpload.addContent(buffer, last); }
@Override public void setContent(InputStream inputStream) throws IOException { if (fileUpload instanceof MemoryFileUpload) { FileUpload memoryUpload = fileUpload; // change to Disk fileUpload = new DiskFileUpload(fileUpload .getName(), fileUpload.getFilename(), fileUpload .getContentType(), fileUpload .getContentTransferEncoding(), fileUpload.getCharset(), definedSize); fileUpload.setMaxSize(maxSize); // release old upload memoryUpload.release(); } fileUpload.setContent(inputStream); }
@Override public void setContent(InputStream inputStream) throws IOException { if (fileUpload instanceof MemoryFileUpload) { FileUpload memoryUpload = fileUpload; // change to Disk fileUpload = new DiskFileUpload(fileUpload .getName(), fileUpload.getFilename(), fileUpload .getContentType(), fileUpload .getContentTransferEncoding(), fileUpload.getCharset(), definedSize); fileUpload.setMaxSize(maxSize); // release old upload memoryUpload.release(); } fileUpload.setContent(inputStream); }
@Override public void setContent(InputStream inputStream) throws IOException { if (fileUpload instanceof MemoryFileUpload) { FileUpload memoryUpload = fileUpload; // change to Disk fileUpload = new DiskFileUpload(fileUpload .getName(), fileUpload.getFilename(), fileUpload .getContentType(), fileUpload .getContentTransferEncoding(), fileUpload.getCharset(), definedSize); fileUpload.setMaxSize(maxSize); // release old upload memoryUpload.release(); } fileUpload.setContent(inputStream); }
@Override public void setContent(InputStream inputStream) throws IOException { if (fileUpload instanceof MemoryFileUpload) { FileUpload memoryUpload = fileUpload; // change to Disk fileUpload = new DiskFileUpload(fileUpload .getName(), fileUpload.getFilename(), fileUpload .getContentType(), fileUpload .getContentTransferEncoding(), fileUpload.getCharset(), definedSize); fileUpload.setMaxSize(maxSize); // release old upload memoryUpload.release(); } fileUpload.setContent(inputStream); }