Examples of MultipartFile


Examples of org.springframework.web.multipart.MultipartFile

  }

  public void testSetValueAsMultipartFileWithBadBytes() throws Exception {
    ByteArrayMultipartFileEditor editor = new ByteArrayMultipartFileEditor();
    MockControl mock = MockControl.createControl(MultipartFile.class);
    MultipartFile file = (MultipartFile) mock.getMock();
    file.getBytes();
    mock.setThrowable(new IOException());
    mock.replay();
    try {
      editor.setValue(file);
      fail("Must have thrown an IllegalArgumentException: IOException thrown when reading MultipartFile bytes");
View Full Code Here

Examples of org.springframework.web.multipart.MultipartFile

   */
  protected void bindMultipartFiles(Map multipartFiles, MutablePropertyValues mpvs) {
    for (Iterator it = multipartFiles.entrySet().iterator(); it.hasNext();) {
      Map.Entry entry = (Map.Entry) it.next();
      String key = (String) entry.getKey();
      MultipartFile value = (MultipartFile) entry.getValue();
      if (isBindEmptyMultipartFiles() || !value.isEmpty()) {
        mpvs.addPropertyValue(key, value);
      }
    }
  }
View Full Code Here

Examples of org.springframework.web.multipart.MultipartFile

*/
public class ByteArrayMultipartFileEditor extends ByteArrayPropertyEditor {

  public void setValue(Object value) {
    if (value instanceof MultipartFile) {
      MultipartFile multipartFile = (MultipartFile) value;
      try {
        super.setValue(multipartFile.getBytes());
      }
      catch (IOException ex) {
        IllegalArgumentException iae = new IllegalArgumentException("Cannot read contents of multipart file");
        iae.initCause(ex);
        throw iae;
View Full Code Here

Examples of org.springframework.web.multipart.MultipartFile

    setValue(text);
  }

  public void setValue(Object value) {
    if (value instanceof MultipartFile) {
      MultipartFile multipartFile = (MultipartFile) value;
      try {
        super.setValue(this.charsetName != null ?
            new String(multipartFile.getBytes(), this.charsetName) :
            new String(multipartFile.getBytes()));
      }
      catch (IOException ex) {
        IllegalArgumentException iae = new IllegalArgumentException("Cannot read contents of multipart file");
        iae.initCause(ex);
        throw iae;
View Full Code Here

Examples of org.springframework.web.multipart.MultipartFile

    }
   
    final String currentAssetId = assetForm.getId();
    final Asset asset = productMarketingService.getProductMarketingAssetById(currentAssetId);
   
    MultipartFile multipartFile = assetForm.getFile();
    if(multipartFile != null){
      long size = multipartFile.getSize();
      asset.setFileSize(size);
    }
   
    try {
      if (multipartFile.getSize() > 0) {
        String pathProductMarketingImage = multipartFile.getOriginalFilename();
        String assetFileRootPath = engineSettingService.getSettingAssetFileRootPath().getDefaultValue();
        assetFileRootPath.replaceAll("\\\\", "/");
        if(assetFileRootPath.endsWith("/")){
          assetFileRootPath = assetFileRootPath.substring(0, assetFileRootPath.length() - 1);
        }
        String assetProductMarketingFilePath = engineSettingService.getSettingAssetProductMarketingFilePath().getDefaultValue();
        assetProductMarketingFilePath.replaceAll("\\\\", "/");
        if(assetProductMarketingFilePath.endsWith("/")){
          assetProductMarketingFilePath = assetProductMarketingFilePath.substring(0, assetProductMarketingFilePath.length() - 1);
        }
        if(!assetProductMarketingFilePath.startsWith("/")){
          assetProductMarketingFilePath = "/" + assetProductMarketingFilePath;
        }
       
        String absoluteFilePath = assetFileRootPath + assetProductMarketingFilePath + "/" + asset.getType().toLowerCase() + "/"  + pathProductMarketingImage;
       
        InputStream inputStream = multipartFile.getInputStream();
        URI url = new URI(absoluteFilePath);
        File fileAsset;
        try {
          fileAsset = new File(url);
        } catch(IllegalArgumentException e) {
View Full Code Here

Examples of org.springframework.web.multipart.MultipartFile

//      }
//    } else {
//      retailer.setWarehouse(null);
//    }
   
        MultipartFile multipartFile = retailerForm.getFile();
        if (multipartFile != null
                && multipartFile.getSize() > 0) {
            UUID uuid = UUID.randomUUID();
            String pathRetailerLogoImage = new StringBuilder(uuid.toString()).append(System.getProperty ("file.separator")).append(FilenameUtils.getExtension(multipartFile.getOriginalFilename())).toString();

            String absoluteFilePath = retailerService.buildRetailerLogoFilePath(retailer, pathRetailerLogoImage);
            String absoluteFolderPath = absoluteFilePath.replace(pathRetailerLogoImage, "");
           
            InputStream inputStream = multipartFile.getInputStream();
            File fileLogo = null;
            File folderLogo = null;
            try {
                folderLogo = new File(absoluteFolderPath);
                folderLogo.mkdirs();
View Full Code Here

Examples of org.springframework.web.multipart.MultipartFile

    @ResponseBody
    @RequestMapping(method = RequestMethod.POST, value = "import/omdl")
    public RpcResult<Page> importPage(HttpServletRequest request, final HttpServletResponse response,
            @RequestParam final String pageName) {
        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
        final MultipartFile multipartFile = multipartRequest.getFile("omdlFile");
        return new RpcOperation<Page>() {
             @Override
             public Page execute() {
               return omdlService.importOmdl(multipartFile, pageName);
             }
View Full Code Here

Examples of org.springframework.web.multipart.MultipartFile

      if (parentFolderIdAsString == null) {
        throw new ServletException("Missing parentFolderId ID");
      }
      Long parentFolderId = Long.parseLong(parentFolderIdAsString);
 
      MultipartFile multipartFile = info.file;
      InputStream is = multipartFile.getInputStream();
      log.debug("fileSystemName: " + info.filename);
 
      ConverterProcessResultList returnError = fileProcessor
          .processFile(info.userId, room_id_to_Store, isOwner, is,
              parentFolderId, info.filename, 0L, ""); // externalFilesId, externalType
View Full Code Here

Examples of org.springframework.web.multipart.MultipartFile

        log.debug("module name missed");
        return;
      }
      boolean userProfile = moduleName.equals("userprofile");
 
      MultipartFile multipartFile = info.file;
      InputStream is = multipartFile.getInputStream();
      String fileSystemName = info.filename;
      fileSystemName = StringUtils.deleteWhitespace(fileSystemName);
 
      UploadCompleteMessage uploadCompleteMessage = new UploadCompleteMessage();
        uploadCompleteMessage.setUserId(info.userId);
View Full Code Here

Examples of org.springframework.web.multipart.MultipartFile

      }
      log.debug("publicSID: " + publicSID);
      info.publicSID= publicSID;

      MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest)request;
      MultipartFile multipartFile = multipartRequest.getFile("Filedata");
      //FIXME encoding HACK
      info.filename = new String (multipartFile.getOriginalFilename().getBytes ("iso-8859-1"), "UTF-8");
      long fileSize = multipartFile.getSize();
      long maxSize = ImportHelper.getMaxUploadSize(configurationDao);
      log.debug("uploading " + fileSize + " bytes");
      if (fileSize > maxSize) {
        throw new ServletException("Maximum upload size: " + maxSize + " exceeded: " + fileSize);
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.