Java Code Examples for org.springframework.web.multipart.MultipartHttpServletRequest

Following code examples demonstrate how to use org.springframework.web.multipart.MultipartHttpServletRequestfrom spring-framework. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use org.springframework.web.multipart.MultipartHttpServletRequestand various code implementation of this class.

	public ObjectNode uploadImage(MultipartHttpServletRequest request, HttpServletResponse response) throws IOException {
		Iterator<String> itr =  request.getFileNames();

		if(null != itr && itr.hasNext()){

			MultipartFile mpf = request.getFile(itr.next());

			if(null != mpf){
				CookUser cookUser = userDao.getUserById(2l);
				cookUser.setImageContent(mpf.getBytes());

			}

		}


		return null;
	} 


Advertisement
Javadoc
Provides additional methods for dealing with multipart content within a servlet request, allowing to

access uploaded files. Implementations also need to override the standard javax.servlet.ServletRequest methods for parameter access, making multipart parameters available.

A concrete implementation is org.springframework.web.multipart.support.DefaultMultipartHttpServletRequest. As an intermediate step, org.springframework.web.multipart.support.AbstractMultipartHttpServletRequest can be subclassed. @author Juergen Hoeller @author Trevor D. Cook @since 29.09.2003 @see MultipartResolver @see MultipartFile @see javax.servlet.http.HttpServletRequest#getParameter @see javax.servlet.http.HttpServletRequest#getParameterNames @see javax.servlet.http.HttpServletRequest#getParameterMap @see org.springframework.web.multipart.support.DefaultMultipartHttpServletRequest @see org.springframework.web.multipart.support.AbstractMultipartHttpServletRequest

Read More
Advertisement