List of usage examples for org.springframework.web.multipart MultipartFile getName
String getName();
From source file:com.slyak.services.file.domain.FileInfo.java
@SneakyThrows public FileInfo(MultipartFile file) { this.size = file.getSize(); this.name = file.getName(); this.contentType = file.getContentType(); this.inputStream = file.getInputStream(); }
From source file:ch.ledcom.jpreseed.web.TemporaryPreseedStore.java
public void addPreseeds(Collection<MultipartFile> preseeds) throws IOException { for (MultipartFile multipartFile : preseeds) { String name = multipartFile.getName(); logger.debug("Adding pressed [{}] to preseed store.", name); Path preseed = tempDir.resolve(name); preseedPaths.add(preseed);/*from w w w . j ava2s.co m*/ try (InputStream in = multipartFile.getInputStream()) { Files.copy(in, preseed, REPLACE_EXISTING); } } }
From source file:service.FilesServiceImpl.java
@Override public void add(MultipartFile file, UsersEntity usersEntity) { FilesEntity fileEntity;/*ww w . j a va 2 s .c om*/ try { fileEntity = new FilesEntity(file.getName(), file.getContentType(), file.getBytes(), usersEntity); this.filesDao.save(fileEntity); } catch (IOException ex) { Logger.getLogger(FilesServiceImpl.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.jayway.restassured.examples.springmvc.controller.FileUploadController.java
@RequestMapping(value = "/fileUpload", method = POST, consumes = MULTIPART_FORM_DATA_VALUE, produces = APPLICATION_JSON_VALUE) public @ResponseBody String fileUpload(@RequestParam MultipartFile file) { return "{ \"size\" : " + file.getSize() + ", \"name\" : \"" + file.getName() + "\" }"; }
From source file:com.yqboots.initializer.web.controller.ProjectInitializerController.java
@RequestMapping(value = "/", method = RequestMethod.POST) public Object startup(@ModelAttribute(WebKeys.MODEL) @Valid final ProjectInitializerForm form, final BindingResult bindingResult, final ModelMap model) throws IOException { if (bindingResult.hasErrors()) { return FORM_URL; }/*from w w w . j a va2 s. com*/ Path path; final MultipartFile file = form.getFile(); if (StringUtils.isNotBlank(file.getName())) { try (InputStream inputStream = file.getInputStream()) { path = initializer.startup(form.getMetadata(), form.getTheme(), inputStream); } } else { path = initializer.startup(form.getMetadata(), form.getTheme()); } final HttpEntity<byte[]> result = FileWebUtils.downloadFile(path, new MediaType("application", "zip", StandardCharsets.UTF_8)); // clear temporary folder final Path parent = path.getParent(); FileUtils.deleteDirectory(parent.toFile()); // clear model model.clear(); return result; }
From source file:com.jayway.restassured.examples.springmvc.controller.FileUploadController.java
@RequestMapping(value = "/fileUpload2", method = POST, consumes = MULTIPART_FORM_DATA_VALUE, produces = APPLICATION_JSON_VALUE) public @ResponseBody String fileUpload2(@RequestParam(value = "controlName") MultipartFile file) { return "{ \"size\" : " + file.getSize() + ", \"name\" : \"" + file.getName() + "\", \"originalName\" : \"" + file.getOriginalFilename() + "\", \"mimeType\" : \"" + file.getContentType() + "\" }"; }
From source file:io.restassured.examples.springmvc.controller.FileUploadController.java
@RequestMapping(value = "/fileUploadWithControlNameEqualToSomething", method = POST, consumes = MULTIPART_FORM_DATA_VALUE, produces = APPLICATION_JSON_VALUE) public @ResponseBody String fileUploadWithControlNameEqualToSomething( @RequestParam(value = "something") MultipartFile file) { return "{ \"size\" : " + file.getSize() + ", \"name\" : \"" + file.getName() + "\", \"originalName\" : \"" + file.getOriginalFilename() + "\", \"mimeType\" : \"" + file.getContentType() + "\" }"; }
From source file:org.unidle.service.AttachmentServiceImpl.java
@Override @Transactional/* w w w . j a v a 2 s .c om*/ public Attachment createAttachment(final MultipartFile file) throws IOException { final Attachment attachment = new Attachment(); attachment.setContent(file.getBytes()); attachment.setContentType(file.getContentType()); attachment.setTitle(file.getName()); return attachmentRepository.save(attachment); }
From source file:org.jasig.portlet.test.mvc.tests.FileUploadController.java
@ActionMapping("fileUploadAction") public void simpleFileUpload(PortletSession portletSession, @RequestParam("file") MultipartFile f) throws IOException { final Map<String, ? extends Object> fileInfo = ImmutableMap.of("size", f.getSize(), "originalFilename", f.getOriginalFilename(), "name", f.getName(), "contentType", f.getContentType(), "byteCount", f.getBytes().length);// w w w . j av a2s .c o m portletSession.setAttribute(UPLOADED_FILE_INFO, fileInfo); }
From source file:com.artivisi.belajar.restful.ui.controller.ApplicationConfigController.java
@RequestMapping(value = "/config/upload", method = RequestMethod.POST) @ResponseBody/*from ww w .j ava 2 s. c o m*/ public List<Map<String, String>> testUpload( @RequestParam(value = "uploadedfiles[]") List<MultipartFile> daftarFoto) throws Exception { logger.debug("Jumlah file yang diupload {}", daftarFoto.size()); List<Map<String, String>> hasil = new ArrayList<Map<String, String>>(); for (MultipartFile multipartFile : daftarFoto) { logger.debug("Nama File : {}", multipartFile.getName()); logger.debug("Nama File Original : {}", multipartFile.getOriginalFilename()); logger.debug("Ukuran File : {}", multipartFile.getSize()); Map<String, String> keterangan = new HashMap<String, String>(); keterangan.put("Nama File", multipartFile.getOriginalFilename()); keterangan.put("Ukuran File", Long.valueOf(multipartFile.getSize()).toString()); keterangan.put("Content Type", multipartFile.getContentType()); keterangan.put("UUID", UUID.randomUUID().toString()); File temp = File.createTempFile("xxx", "xxx"); multipartFile.transferTo(temp); keterangan.put("MD5", createMD5Sum(temp)); hasil.add(keterangan); } return hasil; }