package XXBlob.oracle.apps.pos.xxit.webui;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import oracle.apps.fnd.common.VersionInfo;
import oracle.apps.fnd.framework.OAException;
import oracle.apps.fnd.framework.webui.OAControllerImpl;
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import oracle.cabo.ui.data.DataObject;
import oracle.jbo.domain.BlobDomain;
import java.sql.PreparedStatement;
import java.sql.Connection;
import javax.xml.bind.DatatypeConverter;
/**
* Controller for …
*/
public class XXBlobCo extends OAControllerImpl
{
public static final String RCS_ID=”$Header$”;
public static final boolean RCS_ID_RECORDED =
VersionInfo.recordClassVersion(RCS_ID, “%packagename%”);
/**
* Layout and page setup logic for a region.
* @param pageContext the current OA page context
* @param webBean the web bean corresponding to the region
*/
public void processRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processRequest(pageContext, webBean);
}
/**
* Procedure to handle form submissions for form elements in
* a region.
* @param pageContext the current OA page context
* @param webBean the web bean corresponding to the region
*/
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processFormRequest(pageContext, webBean);
if(pageContext.getParameter(“SubmitBtn”)!=null)
{
try {
DataObject fileUploadData = pageContext.getNamedDataObject(“MessageFileUpload”);
System.out.println(“fileUploadData”+fileUploadData);
if(fileUploadData!=null)
{
String uFileName = (String)fileUploadData.selectValue(null, “UPLOAD_FILE_NAME”);
String contentType = (String) fileUploadData.selectValue(null, “UPLOAD_FILE_MIME_TYPE”);
System.out.println(“uFileName”+uFileName);
System.out.println(“contentType”+contentType);
FileOutputStream output = null;
InputStream input = null;
BlobDomain uploadedByteStream = (BlobDomain)fileUploadData.selectValue(null, uFileName);
System.out.println(“uploadedByteStream”+uploadedByteStream);
File file = new File(“D:\\D”, uFileName);
String myblob =DatatypeConverter.printBase64Binary(uploadedByteStream.toByteArray());
System.out.println(“myblob”+myblob);
output = new FileOutputStream(file);
input = uploadedByteStream.getInputStream();
byte abyte0[] = new byte[0x19000];
int i;
while((i = input.read(abyte0)) > 0)
output.write(abyte0, 0, i);
output.close();
input.close();
}
}
catch(Exception ex) {
throw new OAException(ex.getMessage(), OAException.ERROR);
}
}
}
}