@Override public String getContentType() { return getWrapped().getContentType(); }
@Override public String getFileName() { return getWrapped().getFileName(); }
@Override public InputStream getInputstream() throws IOException { return getWrapped().getInputstream(); }
public void upload() throws IOException { if (this.uploadedFile != null) { this.downloadFile = new DefaultStreamedContent(this.uploadedFile.getInputstream(), this.uploadedFile.getContentType(), this.uploadedFile.getFileName()); } } }
System.out.println(file.getFileName()); byte[] foto = IOUtils.toByteArray(file.getInputstream()); System.out.println(foto); newPerson.setPhoto(foto);
popupDataFile.setProvEntityName(null); if(null != jsonUploadedTempFile && "application/json".equalsIgnoreCase(jsonUploadedTempFile.getContentType())) { //delete and create again can both happen at once stagingEntry.provJson = IOUtils.toString(jsonUploadedTempFile.getInputstream()); stagingEntry.deleteJson = false;
UploadedFile uploadedFile = event.getFile(); String fileName = uploadedFile.getFileName().replaceAll("\\s", "_"); String filePath = temporyDir + "/" + fileName; filePathList.add(filePath); createFile(new File(getWebAppRootPath() + filePath), uploadedFile.getContents());
InputStream stream = item.getInputStream(); long fSize = item.getSize(); int lastIndex = item.getName().lastIndexOf("."); String fileExtension = item.getName().substring(lastIndex); if (!fileExtension.equalsIgnoreCase(".jpg")) { FacesContext.getCurrentInstance().addMessage(
@Override public long getSize() { return getWrapped().getSize(); }
@Override public byte[] getContents() { return getWrapped().getContents(); }
@Override public List<String> getFileNames() { return getWrapped().getFileNames(); }
File file = new File("src/test/TestUploadFile.txt"); InputStream inputStream = new FileInputStream(file); FileUploadEvent event = Mockito.mock(FileUploadEvent.class); UploadedFile uploadedFile = Mockito.mock(UploadedFile.class); Mockito.when(uploadedFile.getFileName()).thenReturn(file.getName()); Mockito.when(uploadedFile.getContentType()).thenReturn("application/octet-stream"); Mockito.when(uploadedFile.getInputstream()).thenReturn(inputStream); Mockito.when(event.getFile()).thenReturn(uploadedFile);
/** * Save uploaded file to server * @param path Location of the server to save file * @param uploadedFile Current uploaded file */ public static void saveUploadedFile(String path, UploadedFile uploadedFile) { try { //First, Generate file to make directories String savedFileName = path + "/" + uploadedFile.getFileName(); File fileToSave = new File(savedFileName); fileToSave.getParentFile().mkdirs(); fileToSave.delete(); //Generate path file to copy file Path folder = Paths.get(savedFileName); Path fileToSavePath = Files.createFile(folder); //Copy file to server InputStream input = uploadedFile.getInputstream(); Files.copy(input, fileToSavePath, StandardCopyOption.REPLACE_EXISTING); } catch (Exception e) { logger.error(e.getMessage()); } finally { } }
@Override public long getSize() { return getWrapped().getSize(); }
@Override public byte[] getContents() { return getWrapped().getContents(); }
handleReplaceFileUpload(event, uFile.getInputstream(), uFile.getFileName(), uFile.getContentType(), event, null); dFileList = FileUtil.createDataFiles(workingVersion, uFile.getInputstream(), uFile.getFileName(), uFile.getContentType(), systemConfig); logger.warning("Failed to process and/or save the file " + uFile.getFileName() + "; " + ioex.getMessage()); return;
public void ajoutP(FileUploadEvent event){ OutputStream out=null; InputStream fileContent=null; try{ UploadedFile uploadedFile= event.getFile(); out= new FileOutputStream(new File("D:/")+uploadedFile.getFileName()); fileContent= uploadedFile.getInputstream(); int read=0; final byte[] bytes= new byte[1024]; while((read= fileContent.read(bytes))!=-1){ out.write(bytes,0,read); } } catch(FileNotFoundException fnfe){ } catch(IOException ioex){ } }
public void handleFileUpload(FileUploadEvent event) { UploadedFile selectedFile = event.getFile(); InputStream inputStream = selectedFile.getInputstream(); ... }
@Override public String getFileName() { return getWrapped().getFileName(); }
@Override public String getContentType() { return getWrapped().getContentType(); }