Spring Framework MultipartFile - 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 MultipartFile class.

This code example shows how to use the following methods:getName
	 * form is taken from the {@link org.springframework.web.multipart.MultipartFile#getName()}. 
	 * @param file multipart file to be added 
	 */ 
	public void addFile(MultipartFile file) {
		Assert.notNull(file, "MultipartFile must not be null");
		this.multipartFiles.add(file.getName(), file);
	} 
 
	@Override 
	public Iterator<String> getFileNames() {
		return this.multipartFiles.keySet().iterator();
	} 
 
	@Override 
	public MultipartFile getFile(String name) {
		return this.multipartFiles.getFirst(name);
	} 
 
	@Override 
	public List<MultipartFile> getFiles(String name) {
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getName
	 * form is taken from the {@link MultipartFile#getName()}. 
	 * @param file multipart file to be added 
	 */ 
	public void addFile(MultipartFile file) { 
		Assert.notNull(file, "MultipartFile must not be null"); 
		this.multipartFiles.add(file.getName(), file); 
	} 
 
	@Override 
	public Iterator<String> getFileNames() { 
		return this.multipartFiles.keySet().iterator(); 
	} 
 
	@Override 
	public MultipartFile getFile(String name) { 
		return this.multipartFiles.getFirst(name); 
	} 
 
	@Override 
	public List<MultipartFile> getFiles(String name) { 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getBytes
	@Override 
	public void setValue(Object value) {
		if (value instanceof MultipartFile) {
			MultipartFile multipartFile = (MultipartFile) value;
			try { 
				super.setValue(multipartFile.getBytes());
			} 
			catch (IOException ex) {
				throw new IllegalArgumentException("Cannot read contents of multipart file", ex);
			} 
		} 
		else if (value instanceof byte[]) {
			super.setValue(value);
		} 
		else { 
			super.setValue(value != null ? value.toString().getBytes() : null);
		} 
	} 
 
	@Override 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getBytes
	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) {
				throw new IllegalArgumentException("Cannot read contents of multipart file", ex);
			} 
		} 
		else { 
			super.setValue(value);
		} 
	} 
 
} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getInputStream
			} 
		} 
		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
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getContentType
 
	@Override 
	public String getMultipartContentType(String paramOrFileName) {
		MultipartFile file = getFile(paramOrFileName);
		if (file != null) {
			return file.getContentType();
		} 
		else { 
			return getMultipartParameterContentTypes().get(paramOrFileName);
		} 
	} 
 
	@Override 
	public HttpHeaders getMultipartHeaders(String paramOrFileName) {
		String contentType = getMultipartContentType(paramOrFileName);
		if (contentType != null) {
			HttpHeaders headers = new HttpHeaders();
			headers.add(CONTENT_TYPE, contentType);
			return headers;
		} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
See Code Examples for Spring Framework MultipartFile Methods: