Examples of MultipartFile


Examples of org.springframework.web.multipart.MultipartFile

  public MultiValueMap<String, MultipartFile> getMultiFileMap() {
    return new LinkedMultiValueMap<String, MultipartFile>(this.multipartFiles);
  }

  public String getMultipartContentType(String paramOrFileName) {
    MultipartFile file = getFile(paramOrFileName);
    if (file != null) {
      return file.getContentType();
    }
    else {
      return null;
    }
  }
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

    paramMap.putAll(getMultipartParameters());
    return paramMap;
  }

  public String getMultipartContentType(String paramOrFileName) {
    MultipartFile file = getFile(paramOrFileName);
    if (file != null) {
      return file.getContentType();
    }
    else {
      return getMultipartParameterContentTypes().get(paramOrFileName);
    }
  }
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

    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) {
        logger.warn("Cannot read contents of multipart file", ex);
        throw new IllegalArgumentException("Cannot read contents of multipart file: " + ex.getMessage());
      }
View Full Code Here

Examples of org.springframework.web.multipart.MultipartFile

  private static final Log logger = LogFactory.getLog(ByteArrayMultipartFileEditor.class);


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

Examples of org.springframework.web.multipart.MultipartFile

        upload.setSizeMax(Constants.UPLOAD_MAX_SIZE)
        try {
          DefaultMultipartHttpServletRequest request1 = (DefaultMultipartHttpServletRequest)request;
            //List fileItems = upload.parseRequest(request1); 
          Map<String,MultipartFile> maps =  request1.getFileMap();
          MultipartFile   file   =   maps.get("image");
          if(null==file)return null;
            //Iterator iter = fileItems.iterator(); 
            //while (iter.hasNext()) { 
            //    FileItem item = (FileItem) iter.next(); 
            //    if (!item.isFormField()) { 
                      
                    String uploadPath = ImageUtils.getUploadPath();
                    String sourcePath = uploadPath + System.getProperty("file.separator") + "gatewayGategoryDetail" + System.currentTimeMillis() +".jpg";
               
                    file.transferTo(new File(sourcePath));
               
                String[] path = sourcePath.split("\\"+System.getProperty("file.separator"));
                    sourcePath = path[path.length-3]+"/"+ path[path.length-2]+"/"+ path[path.length-1];
                 
                  PrintWriter out = response.getWriter();
View Full Code Here

Examples of org.springframework.web.multipart.MultipartFile

    return null;
  }
 
  private File fileUpload(MultipartHttpServletRequest multipartRequest,String key,Merchant merchant){
    Map<String,MultipartFile> maps =  multipartRequest.getFileMap();
    MultipartFile   file   =   maps.get(key);
      try
             String uploadPath = ImageUtils.getUploadPath();
             String sourcePath = uploadPath + System.getProperty("file.separator") + new Date().getTime()+"_"+merchant.getID()+".jpg";
             File newFile = new File(sourcePath);
             file.transferTo(newFile);
         return newFile;
        } catch (Exception e) { 
            e.printStackTrace()
        }
        return null;
View Full Code Here

Examples of org.springframework.web.multipart.MultipartFile

      if(null!=file&&file.exists())file.delete();
    }
  }
  private ProductImage fileUpload(MultipartHttpServletRequest multipartRequest,String key){
    Map<String,MultipartFile> maps =  multipartRequest.getFileMap();
    MultipartFile   file   =   maps.get(key);
      try
        if(null==file)return null;
         String name = file.getOriginalFilename();
         if(null==name||"".equals(name.trim()))return null;
             String[] names = name.split("\\"+System.getProperty("file.separator"));
             name = names[names.length-1];
             names = name.split("\\.");
             name = names[names.length-2];
            
             ProductImage productImage = new ProductImage();
             productImage.setDate(new Date());
             productImage.setDescription(name);
            
             name = productImage.getDate().getTime()+"";
             productImage.setName(name);
            
             String uploadPath = ImageUtils.getUploadPath();
             String sourcePath = uploadPath + System.getProperty("file.separator") + name+".jpg";
             file.transferTo(new File(sourcePath));
       
         String[] path = sourcePath.split("\\"+System.getProperty("file.separator"));
             sourcePath = path[path.length-3]+"/"+ path[path.length-2]+"/"+ path[path.length-1];
             productImage.setSourceURL(sourcePath);
             return productImage;
View Full Code Here

Examples of org.springframework.web.multipart.MultipartFile

  public void testSetValueAsMultipartFile() throws Exception {
    String expectedValue = "That is comforting to know";
    ByteArrayMultipartFileEditor editor = new ByteArrayMultipartFileEditor();
    MockControl mock = MockControl.createControl(MultipartFile.class);
    MultipartFile file = (MultipartFile) mock.getMock();
    file.getBytes();
    mock.setReturnValue(expectedValue.getBytes());
    mock.replay();
    editor.setValue(file);
    assertEquals(expectedValue, editor.getAsText());
    mock.verify();
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.