// Your upload handle would look like public void doPost(HttpServletRequest req, HttpServletResponse res) { // Get the image representation ServletFileUpload upload = new ServletFileUpload(); FileItemIterator iter = upload.getItemIterator(req); FileItemStream imageItem = iter.next(); InputStream imgStream = imageItem.openStream(); // construct our entity objects Blob imageBlob = new Blob(IOUtils.toByteArray(imgStream)); MyImage myImage = new MyImage(imageItem.getName(), imageBlob); // persist image PersistenceManager pm = PMF.get().getPersistenceManager(); pm.makePersistent(myImage); pm.close(); // respond to query res.setContentType("text/plain"); res.getOutputStream().write("OK!".getBytes()); }
final String name = item.getName(); final byte[] bytes = outputStream.toByteArray(); final String contentType = item.getContentType();
final String name = item.getName(); final File file = tmpFile; final String contentType = item.getContentType();
String name = item.getFieldName(); LOG.debug("Uploading file '{}' with item name '{}'", item.getName(), name);
String originFileName = fileStream.getName(); String suffix = FileType.getSuffixByFilename(originFileName);
incrementStringsProcessed(); } else { LOGGER.debug("File field " + name + " with file name " + item.getName() + " detected.");
final FileItemStream fileItemStream = fileItemIter.next(); try { fileItemStream.getName(); fail("Expected exception"); } catch (InvalidFileNameException e) {
assertFalse(item.isFormField()); assertEquals("file1", item.getFieldName()); assertEquals("foo1.tab", item.getName());
public FormPart(FileItemStream stream) { fieldName = stream.getFieldName(); contentType = stream.getContentType(); binaryContent = readBinaryContent(stream); fileName = stream.getName(); if(contentType == null || contentType.contains(MediaType.TEXT_PLAIN)) { textContent = new String(binaryContent); } }
public FormPart(FileItemStream stream) { fieldName = stream.getFieldName(); contentType = stream.getContentType(); binaryContent = readBinaryContent(stream); fileName = stream.getName(); if(contentType == null || contentType.contains(MediaType.TEXT_PLAIN)) { textContent = new String(binaryContent); } }
name = item.getName(); in = item.openStream();
/** * File name. * @return file name. */ public String getFileName(){ return fileItemStream.getName(); }
/** * File name. * * @return file name. */ public String getName() { return fileItemStream.getName(); }
@Override public String getName() { return stream.getName(); }
name = item.getName(); in = item.openStream();
@Override public String getFileName() { String fileName = fileItemStream.getName(); int i = fileName.lastIndexOf('/'); if (i == -1) { i = fileName.lastIndexOf('\\'); } return i != -1 ? fileName.substring(i + 1) : fileName; }
public AutoFileItem(FileItemStream stream) { this.fieldName = stream.getFieldName(); this.contentType = stream.getContentType(); this.isFormField = stream.isFormField(); this.fileName = FilenameUtils.getName(stream.getName()); this.sizeThreshold = Integer.parseInt(Play.configuration.getProperty("upload.threshold", "10240")); this.repository = null; } // ------------------------------- Methods from javax.activation.DataSource
public FormPart(FileItemStream stream) { fieldName = stream.getFieldName(); contentType = stream.getContentType(); binaryContent = readBinaryContent(stream); fileName = stream.getName(); if(contentType == null || contentType.contains(MediaType.TEXT_PLAIN)) { textContent = new String(binaryContent); } }
ServletFileUpload upload = new ServletFileUpload(); FileItemIterator iterator = null; try { iterator = upload.getItemIterator(request); while (iterator.hasNext()) { FileItemStream item = iterator.next(); String filename = item.getName(); } } catch (FileUploadException e) { // handle the error here }
private void handleStream(VaadinSession session, StreamReceiver streamReceiver, StateNode owner, long contentLength, FileItemStream item) throws IOException { String name = item.getName(); InputStream stream = item.openStream(); try { handleFileUploadValidationAndData(session, stream, streamReceiver, name, item.getContentType(), contentLength, owner); } catch (UploadException e) { session.getErrorHandler().error(new ErrorEvent(e)); } }