@Override public long length() { return fileUpload.length(); }
@Override public long getSize() { return fileUpload.length(); }
@Override public long getSize() { return fileUpload.length(); }
/** * Parse FileUpload to {@link FileItem}. * * @param fileUpload netty http file upload */ private void parseFileUpload(FileUpload fileUpload) throws IOException { if (!fileUpload.isCompleted()) { return; } FileItem fileItem = new FileItem(); fileItem.setName(fileUpload.getName()); fileItem.setFileName(fileUpload.getFilename()); // Upload the file is moved to the specified temporary file, // because FileUpload will be release after completion of the analysis. // tmpFile will be deleted automatically if they are used. Path tmpFile = Files.createTempFile( Paths.get(fileUpload.getFile().getParent()), "blade_", "_upload"); Path fileUploadPath = Paths.get(fileUpload.getFile().getPath()); Files.move(fileUploadPath, tmpFile, StandardCopyOption.REPLACE_EXISTING); fileItem.setFile(tmpFile.toFile()); fileItem.setPath(tmpFile.toFile().getPath()); fileItem.setContentType(fileUpload.getContentType()); fileItem.setLength(fileUpload.length()); fileItems.put(fileItem.getName(), fileItem); }
/** * Parse FileUpload to {@link FileItem}. * * @param fileUpload netty http file upload */ private void parseFileUpload(FileUpload fileUpload) throws IOException { if (!fileUpload.isCompleted()) { return; } FileItem fileItem = new FileItem(); fileItem.setName(fileUpload.getName()); fileItem.setFileName(fileUpload.getFilename()); // Upload the file is moved to the specified temporary file, // because FileUpload will be release after completion of the analysis. // tmpFile will be deleted automatically if they are used. Path tmpFile = Files.createTempFile( Paths.get(fileUpload.getFile().getParent()), "blade_", "_upload"); Path fileUploadPath = Paths.get(fileUpload.getFile().getPath()); Files.move(fileUploadPath, tmpFile, StandardCopyOption.REPLACE_EXISTING); fileItem.setFile(tmpFile.toFile()); fileItem.setPath(tmpFile.toFile().getPath()); fileItem.setContentType(fileUpload.getContentType()); fileItem.setLength(fileUpload.length()); fileItems.put(fileItem.getName(), fileItem); }
@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 long size() { return upload.length(); } }
@Override public long length() { return fileUpload.length(); }
@Override public long length() { return fileUpload.length(); }
@Override public long length() { return fileUpload.length(); }
@Override public long length() { return fileUpload.length(); }
/** * Get content length. * * @return Length of posted / uploaded content. */ @Override public long getContentLength() { if (fileUpload != null) { return fileUpload.length(); } if (buffer != null) { return buffer.readableBytes(); } return 0; }
@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); }
/** * Parse FileUpload to {@link FileItem}. * * @param fileUpload netty http file upload */ private void parseFileUpload(FileUpload fileUpload) throws IOException { if (!fileUpload.isCompleted()) { return; } FileItem fileItem = new FileItem(); fileItem.setName(fileUpload.getName()); fileItem.setFileName(fileUpload.getFilename()); // Upload the file is moved to the specified temporary file, // because FileUpload will be release after completion of the analysis. // tmpFile will be deleted automatically if they are used. Path tmpFile = Files.createTempFile( Paths.get(fileUpload.getFile().getParent()), "blade_", "_upload"); Path fileUploadPath = Paths.get(fileUpload.getFile().getPath()); Files.move(fileUploadPath, tmpFile, StandardCopyOption.REPLACE_EXISTING); fileItem.setFile(tmpFile.toFile()); fileItem.setPath(tmpFile.toFile().getPath()); fileItem.setContentType(fileUpload.getContentType()); fileItem.setLength(fileUpload.length()); fileItems.put(fileItem.getName(), fileItem); }
@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 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 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); }
public static MultipartFile create(FileUpload fileUpload) { try { MultipartFile _file = new MultipartFile(); _file.setContent(fileUpload.get()); _file.setContentType(fileUpload.getContentType()); _file.setSize(fileUpload.length()); _file.setName(fileUpload.getFilename()); return _file; } catch (Exception ex) { // ignore exception } return null; } }