package tvark.beans;

import java.io.IOException;

import org.apache.myfaces.custom.fileupload.UploadedFile;

import tvark.jsf.JsfUtils;

public class UploadBean {
	
	private static final String SER_KEY_BYTES = "uploaded_bytes";
	
	public UploadedFile getFile() {
		return null;
	}

	public byte[] getBytes() {
		return (byte[]) JsfUtils.loadFromSession(SER_KEY_BYTES);
	}
	
	public void setFile(UploadedFile file) {
		try {
			byte[] bytes = file.getBytes();
			JsfUtils.persistInSession(bytes, SER_KEY_BYTES);
		} catch (IOException e) {
			throw new RuntimeException(e);
		} finally {
		}
	}
	
	public String upload() {
		return JsfUtils.Outcome.PARAMETERS;
	}
}
