Message File Upload in OAF

Message File Upload in OAF
--==========================================

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;

--===============================================

  public void processRequest(OAPageContext pageContext, OAWebBean webBean)
  {
    super.processRequest(pageContext, webBean);
  }

--===============================================

  public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
  {
    super.processFormRequest(pageContext, webBean);
    /* Oracle Technical Shooter */
    
         if(pageContext.getParameter("Submit")!=null) 
         { 
          File_Upload(pageContext,webBean);     
         } 
             
     /* Oracle Technical Shooter */
  }
  
  /* File_Upload */
  
   public void File_Upload(OAPageContext pageContext,OAWebBean webBean)
   { //String filePath = "C:\\Users\\manoj.kumar11\\Desktop\\Destination"; // /* For Local System*/
        String filePath = "/u08/STG_APP/apps/apps_st/comn/java/classes/xxsd/oracle/apps/Buyer_Recon"; /* F0r Server */
    
    String fileUrl = null;
    try
    {
     DataObject fileUploadData =  pageContext.getNamedDataObject("Upload_File");

      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("Your File Name || "+uFileName);
         System.out.println("Your File Type  || "+contentType);

      FileOutputStream output = null;
      InputStream input = null;

      BlobDomain uploadedByteStream = (BlobDomain)fileUploadData.selectValue(null, uFileName);
                              
      File file = new File( filePath, uFileName);  
      System.out.println("Your File Move to Destination ||"+file);

      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);
    }    
   }

Comments

Popular posts from this blog

E-Text Report In Fusion | Types of E-Text reports

Supplier API's

How to pass default Parameter in cursor