Spring Framework MultipartException - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework MultipartException class.

This code example shows how to use the following methods:
		if (this.multipartRequest instanceof StandardMultipartHttpServletRequest) { 
			try { 
				return this.multipartRequest.getPart(this.partName).getInputStream(); 
			} 
			catch (Exception ex) { 
				throw new MultipartException("Could not parse multipart servlet request", ex); 
			} 
		} 
		else { 
			MultipartFile file = this.multipartRequest.getFile(this.partName); 
			if (file != null) { 
				return file.getInputStream(); 
			} 
			else { 
				String paramValue = this.multipartRequest.getParameter(this.partName); 
				return new ByteArrayInputStream(paramValue.getBytes(FORM_CHARSET)); 
			} 
		} 
	} 
 
6
CodeRank
This code example shows how to use the following methods:
	} 
 
	private static void assertIsMultipartRequest(HttpServletRequest request) { 
		String contentType = request.getContentType(); 
		if (contentType == null || !contentType.toLowerCase().startsWith("multipart/")) { 
			throw new MultipartException("The current request is not a multipart request"); 
		} 
	} 
 
	private String getPartName(MethodParameter parameter) { 
		RequestPart annot = parameter.getParameterAnnotation(RequestPart.class); 
		String partName = (annot != null ? annot.value() : ""); 
		if (partName.length() == 0) { 
			partName = parameter.getParameterName(); 
			Assert.notNull(partName, "Request part name for argument type [" + parameter.getParameterType().getName() + 
					"] not specified, and parameter name information not found in class file either."); 
		} 
		return partName; 
	} 
 
5
CodeRank
This code example shows how to use the following methods:
        if (size > 0) {
            try { 
                return getBytes().length;
            } catch (IOException e) {
 
                throw new MultipartException("Something went wrong here");
            } 
 
        } 
        return size;
    } 
 
    public byte[] getBytes() throws IOException {
        if(bytes == null) {
            bytes =  IOUtils.toByteArray(item.openStream());
        } 
 
        return bytes;
 
 
4
CodeRank