@Override public InputStream getInputStream() throws IOException { return item.getInputStream(); }
@Override public void transferTo(Path dest) throws IOException, IllegalStateException { if (!isAvailable()) { throw new IllegalStateException("File has already been moved - cannot be transferred again"); } FileCopyUtils.copy(this.fileItem.getInputStream(), Files.newOutputStream(dest)); }
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { List<FileItem> items = new ServletFileUpload(new DiskFileItemFactory()).parseRequest(request); for (FileItem item : items) { if (item.isFormField()) { // Process regular form field (input type="text|radio|checkbox|etc", select, etc). String fieldName = item.getFieldName(); String fieldValue = item.getString(); // ... (do your job here) } else { // Process form file field (input type="file"). String fieldName = item.getFieldName(); String fileName = FilenameUtils.getName(item.getName()); InputStream fileContent = item.getInputStream(); // ... (do your job here) } } } catch (FileUploadException e) { throw new ServletException("Cannot parse multipart request.", e); } // ... }
@Override public InputStream getInputStream() throws IOException { if (!isAvailable()) { throw new IllegalStateException("File has been moved - cannot be read again"); } InputStream inputStream = this.fileItem.getInputStream(); return (inputStream != null ? inputStream : StreamUtils.emptyInput()); }
@Override public InputStream getInputstream() throws IOException { return sizeLimit == null ? fileItem.getInputStream() : new BoundedInputStream(fileItem.getInputStream(), sizeLimit); }
BufferedReader fileItemReader(FileItem fileItem) throws IOException { return RequestUtils.getBufferedXMLReader(fileItem.getInputStream(), XML_LOOKAHEAD); }
@Override public void transferTo(Path dest) throws IOException, IllegalStateException { if (!isAvailable()) { throw new IllegalStateException("File has already been moved - cannot be transferred again"); } FileCopyUtils.copy(this.fileItem.getInputStream(), Files.newOutputStream(dest)); }
@Override public InputStream getInputStream() throws IOException { if (!isAvailable()) { throw new IllegalStateException("File has been moved - cannot be read again"); } InputStream inputStream = this.fileItem.getInputStream(); return (inputStream != null ? inputStream : StreamUtils.emptyInput()); }
/** * Place the data from {@link FileItem} into the file location specified by this {@link FilePath} object. */ public void copyFrom(FileItem file) throws IOException, InterruptedException { if(channel==null) { try { file.write(writing(new File(remote))); } catch (IOException e) { throw e; } catch (Exception e) { throw new IOException(e); } } else { try (InputStream i = file.getInputStream(); OutputStream o = write()) { org.apache.commons.io.IOUtils.copy(i,o); } } }
for (FileItem item : formItems) { if (item.isFormField()) { // Process regular form field (input type="text|radio|checkbox|etc", select, etc). String fieldname = item.getFieldName(); String fieldvalue = item.getString(); // ... (do your job here) } else { // Process form file field (input type="file"). String fieldname = item.getFieldName(); String filename = FilenameUtils.getName(item.getName()); InputStream filecontent = item.getInputStream(); // ... (do your job here) } }
final File archiveFile = new File(tempDir, name); out = new BufferedOutputStream(new FileOutputStream(archiveFile)); IOUtils.copy(item.getInputStream(), out); out.close();
/** * Do a finger-print check. */ @RequirePOST public void doDoFingerprintCheck( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException { // Parse the request try (MultipartFormDataParser p = new MultipartFormDataParser(req)) { if (isUseCrumbs() && !getCrumbIssuer().validateCrumb(req, p)) { // TODO investigate whether this check can be removed rsp.sendError(HttpServletResponse.SC_FORBIDDEN, "No crumb found"); } rsp.sendRedirect2(req.getContextPath()+"/fingerprint/"+ Util.getDigestOf(p.getFileItem("name").getInputStream())+'/'); } }
public InputStream getInputStream() throws IOException { return item.getInputStream(); }
public InputStream getInputStream() throws IOException { return fileItem.getInputStream(); }
@NonNull @Override public InputStream getStream() throws IOException { if (!isAvailable()) { throw new IllegalStateException("File has been moved - cannot be read again."); } InputStream inputStream = fileItem.getInputStream(); return (inputStream != null ? inputStream : IOUtils.createEmptyInput()); }
List<FileItem> items = upload.parseRequest(requestContext); for (FileItem item : items) { InputStream uploadedStream = item.getInputStream(); ModuleUtil.insertModuleFile(uploadedStream, item.getName());
@Override public InputStream getInputStream() { try { return file.getInputStream(); } catch(final IOException ex) { throw new RuntimeException(ex); } }
/** * @return an InputStream to read the binary content of this attachment. * @since 2.3M2 */ public InputStream getContentInputStream() { try { return new AutoCloseInputStream(this.file.getInputStream()); } catch (IOException e) { throw new RuntimeException("Failed to get InputStream", e); } }
public java.io.InputStream getStreamData() { try { return _fi.getInputStream(); } catch (IOException ex) { throw new UiException("Unable to read " + _fi, ex); } }
protected void processFile(FileItem item, String name) { try { UploadedFile upload = new DefaultUploadedFile(item.getInputStream(), item.getName(), item.getContentType(), item.getSize()); parameters.setParameter(name, name); request.setAttribute(name, upload); logger.debug("Uploaded file: {} with {}", name, upload); } catch (IOException e) { throw new InvalidParameterException("Cant parse uploaded file " + item.getName(), e); } }