Create OS directory and write file from BLOB

Hi,
i want to create via a stored PL/SQL procedure a directory in an OS filesystem (Windows NTFS) and afterwards write a file (Type: DOC, PDF, ...) from a BLOB table to that directory.
The filesystem is one to the node (where the database instance 10g is running) mapped fileserver directory.
The complete environment is Windows XP (node of the database instance and the mapped fileserver directory).
Maybe i have to use a Java stored procedure - if yes, where can i find an appropriate example and documentation?
Has somebody an idea how to achieve this?
Many thanks in advance.
Best regards,
Martin

You can find lot of java stored procedures samples here
http://www.oracle.com/technology/sample_code/tech/java/jsp/oracle9ijsp.html
And java code to create a directory is here.
http://javaalmanac.com/egs/java.io/CreateDir.html

Similar Messages

  • Create directory and write files to it

    i have installed tomcat 3.2.3 and am using ms access as databse.
    through my jsp code i need to create random directories on the server and write files to it(need to have write access on the directories).
    how do i do it?? thanx in advance.

    You can include java.io in ur jsp page only using
    <%@ page language="java" import="java.io.File %>
    then u can create directories on the fly on the server using
    mkdir(s) method of the FILE Object.
    You will have to specify the path while creating a File object.
    You will get the application's path using
    application.getRealPath() method .... to wich u can append
    whatever u will like...
    Once u got the directory u can also create files using file object
    Hope this is of any help...
    Feel free toa sk if i could not satisfy u...

  • Are JDev autogenerated paths needed to create ear, war and jar files ?

    Hi
    We want to create ear, war and jar files from Ant build script generated from JDeveloper 11.1.1.7.
    We also like to use ojdeploy with it.
    In the process of creating build.xml files from projects, we see these paths.
    We also have standalone Weblogic installed with ADF runtime 11.1.1.7
    Questions:
    1- Do we need these path ids to generate ear, jar, war files properly and then deploy the ear to our standalone Weblogic so that our webapp can run ok ?
    2- Why are they generated, if they are not needed
    From research, it appears that we don't need these paths except to keep ant targets of init, compile, exec etc with ojdeploy.
    3- Is that true ?
    We are afraid that because no paths are listed in the build.xml, then when we deploy the ear app, it cant use the ADF runtime on the standalone WLS.
    Thanks in advance for answering.
    Sincerely
    eg of paths generated below:
      <path id="library.SOA.Designtime"/>
      <path id="library.SOA.Runtime"/>
      <path id="library.BPEL.Runtime"/>
      <path id="library.Mediator.Runtime"/>
      <path id="library.MDS.Runtime">
        <pathelement location="{oracle.middleware}/oracle_common/modules/oracle.mds_11.1.1/mdsrt.jar"/>
      </path>
      <path id="library.BC4J.Service.Runtime">
        <pathelement location="{oracle.middleware}/oracle_common/modules/oracle.adf.model_11.1.1/adfbcsvc.jar"/>
        <pathelement location="{oracle.middleware}/oracle_common/modules/oracle.adf.model_11.1.1/adfbcsvc-share.jar"/>
        <pathelement location="{oracle.middleware}/oracle_common/modules/commonj.sdo_2.1.0.jar"/>
        <pathelement location="{oracle.middleware}/modules/org.eclipse.persistence_1.1.0.0_2-1.jar"/>
        <pathelement location="{oracle.middleware}/oracle_common/modules/oracle.webservices_11.1.1/wsclient.jar"/>
        <pathelement location="{oracle.middleware}/oracle_common/modules/oracle.web-common_11.1.1.jar"/>
      </path>
      <path id="library.TopLink">
        <pathelement location="{oracle.middleware}/modules/com.oracle.toplink_1.0.0.0_11-1-1-5-0.jar"/>
        <pathelement location="{oracle.middleware}/modules/org.eclipse.persistence_1.1.0.0_2-1.jar"/>
        <pathelement location="{oracle.middleware}/modules/com.bea.core.antlr.runtime_2.7.7.jar"/>
        <pathelement location="{oracle.middleware}/modules/javax.persistence_1.0.0.0_2-0-0.jar"/>
      </path>
      <path id="library.Oracle.Rules"/>
      <path id="classpath">
        <path refid="library.SOA.Designtime"/>
        <path refid="library.SOA.Runtime"/>
        <path refid="library.BPEL.Runtime"/>
        <path refid="library.Mediator.Runtime"/>
        <path refid="library.MDS.Runtime"/>
        <path refid="library.BC4J.Service.Runtime"/>
        <path refid="library.TopLink"/>
        <path refid="library.Oracle.Rules"/>
      </path>

    There are two different things here. Using ant to build the class files and then building an ear from the class files and other resources.
    The building part needs the libraries if you use javac as compiler. Building an ear file only needs the path to the jar files which are packed into the ear.
    In this sense you need the pages you see in the build.xml.
    Then Jdev offers another way: ojdeploy. This tool is a Jdev without a gui.
    You can use this tool and build the classes for each project of a workspace and to build build war and ear file. This is just like you click the rebuild button for each project and then the deploy the projects and application. If you use this approach you don't need the generated path ids as the whole build process is done inside Jdev as it's done on your developer pc.
    Timo

  • About "Upload and download files from ADF into blob type colum."

    hi
    Using JDeveloper 10.1.3.3.0 I have tried the example available for download from this blog post by Jakub Pawlowski:
    "Upload and download files from ADF into blob type colum."
    at http://kuba.zilp.pl/?id=1
    First a thank you to Jakub for this interesting example.
    I have a question about a PDF file that I uploaded using the example.
    The file has a size of 10445518 bytes.
    After I upload that file, the blob column has a value with a size of 10445516 bytes, 2 bytes less.
    SQL> select file_name, dbms_lob.getlength(stored_file) from blob_table;
    FILE_NAME
    DBMS_LOB.GETLENGTH(STORED_FILE)
    ADF-DeveloperGuide-4GL-B25947_01.pdf
                           10445516If I download that file using the example, it has the same size as the blob value, 10445516 bytes.
    If I open the downloaded file, using Adobe Reader 8.1.1, it first shows this message:
    "The file is damaged but is being repaired."
    After that, there is not problem using the PDF file in Adobe Reader.
    I have tried this with both Internet Explorer 6 and Firefox 2.0.0.11.
    I have also tried this with other (smaller) files, and those upload and download correctly.
    question:
    Why are those 2 bytes lost during upload?
    many thanks
    Jan Vervecken

    Hi!
    I can only post you my code that works for me and as I said I had same problems but can't remember what solved them. My code:
      public void fileUploaded(ValueChangeEvent event)
        FacesContext fc = FacesContext.getCurrentInstance();
        UploadedFile file = (UploadedFile) event.getNewValue();
        if (file != null && file.getLength() > 0)
          // here I have some messages written and a call to the method on AM to save the uploaded file to the DB
      private BlobDomain newBlobDomainForInputStream(InputStream in)
        throws SQLException, IOException
        BlobDomain loBlob = new BlobDomain();
        OutputStream out = loBlob.getBinaryOutputStream();
        writeInputStreamToWriter(in, out);
        in.close();
        out.close();
        return loBlob;
      private static void writeInputStreamToWriter(InputStream in,
                                                   OutputStream out)
        throws IOException
        byte[] buffer = new byte[8192];
        int charsRead = 0;
        while ((charsRead = in.read(buffer, 0, 8192)) != -1)
          out.write(buffer, 0, charsRead);
       * Launch the upload - see fileUploaded() for actual upload handling.
       * @return null navigation event - we stay on this page
      public String UploadButton_action()
        if (this.getMyInputFile().getValue() == null)
          FacesContext context = FacesContext.getCurrentInstance();
          FacesMessage message =
            new FacesMessage(FacesMessage.SEVERITY_WARN, JSFUtils.getStringFromBundle("fileupload.emptyfielderror"),
                             null);
          context.addMessage(this.getMyInputFile().getId(), message);
        return null;
       * Setter for inputFile UI Component.
       * @param inputFile inputFile UI component
      public void setMyInputFile(CoreInputFile inputFile)
        this.myInputFile = inputFile;
       * Getter for inputFile UI Component.
       * @return inputFile UI component
      public CoreInputFile getMyInputFile()
        return myInputFile;
      }fileUploaded is a valueChangeListener on inputFile and UploadButton_action is as the name says the action for upload button.
    Hope this helps. If not, than your problem is probably not the same as mine was, although the message about file corrupted was the same.
    Next thing you can check in this case is if your file exceeds max file upload size. I don't know the exact default value, but if the file is too long I think this upload logic will upload only a part of the file and save it to the DB which can also lead to the same file corrupted error.
    You can set the max upload value in web.xml like this:
    <context-param>
    <!-- Maximum memory per request (in bytes) -->
    <param-name>oracle.adf.view.faces.UPLOAD_MAX_MEMORY</param-name>
    <!-- Use 5000K -->
    <param-value>5120000</param-value>
    </context-param>
    <context-param>
    <!-- Maximum disk space per request (in bytes) -->
    <param-name>oracle.adf.view.faces.UPLOAD_MAX_DISK_SPACE</param-name>
    <!-- Use 10,000K -->
    <param-value>15360000</param-value>
    </context-param>

  • Read and write info from/to file available at client side.

    Hi,
    I have some table name in one CSV file at client side.
    once you get list of tables name from input CSV file at client side.
    Need to run one query to know total rows and size of table in MB , this i need to repeat for all tables which i got from input file.
    finally write 'table name | total rows | size of table in MB' whole info in another CSV file at client side. this output CSV file name will contain timestamp.
    Please guide me in detail how to read and write file avail at client side.
    I am using sql developer at client side.
    version : oracle11g
    Thanks in advance.

    This is a simple SQL question and this forum is for SQLDEveloper, however, this is a question for our SQL*Plus support which can help with this.
    clear SCREEN
    set FEEDBACK off
    set head off
    --Gather stats to populate rownums and avg length of rows.
    --These are not exact sizes (obviously) but you get the idea.
    begin
    dbms_stats.gather_schema_stats ('<YOUR_SCHEMA');
    end;
    select TABLE_NAME||','||NUM_ROWS||','||ROUND((NUM_ROWS*AVG_ROW_LEN)/(1024*1024)) CSV
    from USER_TABLES
    where num_rows is not null order by num_rows desc;

  • Need to create PDF and Spreadsheet file from RDF file when user passes the parameters

    Hi Everyone,
    I am beginner as report developer ,i came across one  issue when the requirement came from the client regarding generating EXCEL FILE and PDF FILE from same RDF file .
    I was able to generate the PDF file but i when i tried to create excel file it does not include the margin in it, also the cell border are not seen( file comes with data but with no CELL borders), I have also attached screenshot for reference .
    View image: problem
    or
    http://i43.tinypic.com/2mq017k.jpg
    Software Used :
    Oracle reports Developer : 11g 1.2.3.0
    Thanks ,
    Harshil

    Dear  Olga12,
    Thanks a lot for your quick reply.
    When i suggested the solution to my client  for creating two separate templates attached to same data definition , they declined and argued that  we cant create 2 separate templates for all reports( more than 200 reports).
    Is there any way to create the PDF/EXCEL from same RDF other than creating two separate templates ?
    Thanks ,
    Harshil

  • How to retrieve xml file from BLOB and display on browser with css/xslt

    Hi All,
    I am new to xml. I am storing my xml file into BLOB in database. Now in my jsp page I want to retrieve this xml file from BLOB and display in HTML/CSS/XSLT form...
    Pl. guide me.. any docs..?? Logic...??
    Thanks in Advance.
    Sandeep Oza

    Hello Sandeep!
    I'm not familiar with jsp but logic should be as follows:
    -in jsp page instantiate XML parser
    -load specified BLOB into parser
    Now you may traverse the XML tree or you might load XSL file and use transform method to transform XML according to XSL file.
    I have an example where I'm selecting XML straight from relational database and then transform it using XSL into appropriate HTML output, but it's written in PSP.
    You can try http://www.w3schools.com/default.asp for basics on XML, CSS, XSL. It's easy to follow with good examples.
    Regards!
    miki

  • Creating Folder and Accessing Files from Folders in mobile phone

    Hello Friends,
    I am doing my project where I need to create folders and accessing files from those folders in java enabled mobile phones.But I do not know the required tasks for this.Any type of help is highly appreciated.
    Greeting
    Saadi

    You have to get the classname of the Items you receive from getitems.
    There you have only to look for Folder.CLASS_NAME. Example:
    ifsFol sorted by names in ascending order (names of folders and files)
    String[] sort_attributes = {"NAME"};
    //sort will be ascending
    boolean [] sort_orders = {true};
    oracle.ifs.common.SortSpecification sort = new oracle.ifs.common.SortSpecification(sort_attributes, sort_orders);
    ifsFol.setSortSpecification(sort);
    PublicObject[] contents = ifsFol.getItems();
    System.out.println("Here are the names of the items in folder: ");
    for (int i=0; i < contents.length; i++) {
    if (contents.getClassname().equals(Folder.CLASS_NAME)) {
    System.out.println(contents[i].getName());
    null

  • Essbase Administration Console error "failed to create client directory to write error file"

    I am getting the following error while trying to load data using EAS v11.1.2.3
    "failed to create client directory to write error file"
    Any known root cause for this.

    Check the default error directory while loading data? The error file in 11.1.2.2 points to C:\Oracle\Middleware\EPMSystem11R1\products\Essbase\eas\client, which is already on the system where EAS is installed.
    If the folder is not there then it is a bug, however you can change it to an existing path.
    Regards
    Celvin
    http://www.orahyplabs.com

  • Read and Write Files to user from Forms Server

    We are developing an application that requires us to rread and write files to the user system. We are deploying using the developer/forms server and this is not happenning. The text_io package and the d2wkutil operate on the application server system, not the user system. So is there a method to read the file contents into the app and write files out to the user system across the web. Thanks.

    developer6 can interact with javabeans. the javabean runs as an applet on the client machine. all you have to do is setup a javabean that read and write to your client machine.
    when you test your application, work with java console open so you'll be able to debug your appliacion, if you'll receive java security execption you may need to sign this javabean. look at sun site for info regarding the usage of javakey for signing java classes and jars.

  • Creating ear and war file from deploy file programatically

    Hi All,
    Is there any API available in oc4j to create an ear or war file from a .deploy file...........??
    Thanx in advance.

    There isn't a public API that let's you hook up to the deploy file in JDeveloper.
    You might be able to achieve this with the JDeveloper Ant task:
    http://www.oracle.com/technology/products/jdev/htdocs/partners/addins/exchange/anttasks/index.html

  • How can I open different binary files from BLOB column ?

    If we store some type of binary file (XLS, DOC, PDF, EML and so on, not only pictures) in BLOB column how can I show the different contents? We use designer and forms 9i with PL/SQL.
    How can I copy the files from BLOB to file in a directory or how can I pass BLOB's content to the proper application directly to open it?

    The mime type is just a string as explained above (e.g. application/pdf...). There are lot of samples here and on metalink.
    E.g. add a column mime_type varchar(30) to your blob table. Create a procedure similar to the following:
    PROCEDURE getblob
    (P_FILE IN VARCHAR2
    IS
    vblob blob;
    vmime_type myblobs.mime_type%type;
    length number;
    begin
         select document, mime_type into vblob,vmime_type from myblobs where docname = p_file;
         length := dbms_lob.getlength(vblob);
         if length = 0 or vblob is null then
         htp.p('Document not available yet.');
         else
         owa_util.mime_header(vmime_type);
         htp.p('Content-Length: ' || dbms_lob.getlength(vblob));
         owa_util.http_header_close;
         wpg_docload.download_file(vblob);                
         end if;
    exception
         when others then
         htp.p(sqlerrm);
    END;
    Create a DAD on your application server (refer to documentation on how to create a DAD).
    Display the blob from forms (e.g. on a when-button-pressed trigger):
    web.show_document('http://myserver:port/DAD/getblob?p_file=myfilename','_blank');
    For storing blobs in a directory on your db server take a look at the dbms_lob package.
    For storing blobs in a directory on your app server take a look at WebUtil available on OTN.
    HTH
    Gerald Krieger

  • Getting issue while downloading 4 to 5 gb file from blob storage.

    Hi i have to download a file from blob storage upto 3 to 5 gb .
    Below is my code:
    Label lblfilename = (Label)row.FindControl("lblGrid_filename");
        Label lblfilesize = (Label)row.FindControl("lblGrid_hidfileSize");
        string downloadfile = lblfilename.Text.ToString();
       // DownloadFileFromBlob(downloadfile, CONTAINER, ACCOUNTKEY);
        AccountFileTransfer = CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName=" + ACCOUNTNAME + ";AccountKey=" + ACCOUNTKEY);
        if (AccountFileTransfer != null)
            BlobClientFileTransfer = AccountFileTransfer.CreateCloudBlobClient();
            ContainerFileTransfer = BlobClientFileTransfer.GetContainerReference(CONTAINER);
            ContainerFileTransfer.CreateIfNotExist();
            BlobRequestOptions options = new BlobRequestOptions();
            options.Timeout = new TimeSpan(0, 180, 0);
        var data = Regex.Match(lblfilesize.Text.ToString(), @"\d+").Value;
        int value32;
        Int64 value64;
        var blobSize = 0L;
        var blockSize = 0L;
        var offset = 0L;
        if (int.TryParse(data, out value32))
            blobSize = Convert.ToInt32(lblfilesize.Text.ToString());
        else if (Int64.TryParse(data, out value64))
            blobSize = Convert.ToInt64(lblfilesize.Text.ToString());
        var blob = ContainerFileTransfer.GetBlockBlobReference(downloadfile);
        var sasUrl = blob.Uri.AbsoluteUri;
        CloudBlockBlob blockBlob = new CloudBlockBlob(sasUrl);
        //blobSize = Convert.ToInt32(lblfilesize.Text.ToString());
        blockSize = 5 * 1024 * 1024;
        Response.Clear();
        Response.ContentType = "APPLICATION/OCTET-STREAM";
        System.String disHeader = "Attachment; Filename=\"" + blockBlob.Name + "\"";
        //Response.AppendHeader("Content-Disposition", disHeader);
        for (offset = 0; offset < blobSize; offset += blockSize)
            using (var blobStream = blockBlob.OpenRead())
                if ((offset + blockSize) > blobSize)
                    blockSize = (blobSize - offset);
                byte[] buffer = new byte[blockSize];
                blobStream.Read(buffer, 0, buffer.Length);
                Response.BinaryWrite(buffer);
                Response.Flush();
        Response.End();
    SNAPSHOT of error:
    Pawan

    Hi Will thanks per the reply
    I have make some changes in the code and now i am using the v4.0.30319 azure storage for downloading and able to download a file upto 3.5 GB. Now the problem is that each file size is showing 0 KB.
    Here is my code and snapshot:
      Button btndownloadrow = (Button)sender;
        GridViewRow row = (GridViewRow)btndownloadrow.NamingContainer;
        Label lblfilename = (Label)row.FindControl("lblGrid_filename");
        Label lblfilesize = (Label)row.FindControl("lblGrid_hidfileSize");
        string downloadfile = lblfilename.Text.ToString();
        CloudStorageAccount AccountFileTransfer = CloudStorageAccount.Parse("DefaultEndpointsProtocol=http;AccountName=" + ACCOUNTNAME + ";AccountKey=" + ACCOUNTKEY);
        // Create the blob client.
        CloudBlobClient BlobClientFileTransfer = AccountFileTransfer.CreateCloudBlobClient();
        // Retrieve reference to a previously created container.
        CloudBlobContainer ContainerFileTransfer = BlobClientFileTransfer.GetContainerReference("filetransfer");
        if (AccountFileTransfer != null)
            BlobClientFileTransfer = AccountFileTransfer.CreateCloudBlobClient();
            CloudBlockBlob pageBlob = ContainerFileTransfer.GetBlockBlobReference(CONTAINER);
            ContainerFileTransfer.CreateIfNotExists();
            BlobRequestOptions options = new BlobRequestOptions();
            options.ServerTimeout= new TimeSpan(0, 180, 0);
        var data = Regex.Match(lblfilesize.Text.ToString(), @"\d+").Value;
        int value32;
        Int64 value64;
        var blobSize = 0L;
        var blockSize = 0L;
        var offset = 0L;
        if (int.TryParse(data, out value32))
            blobSize = Convert.ToInt32(lblfilesize.Text.ToString());
        else if (Int64.TryParse(data, out value64))
            blobSize = Convert.ToInt64(lblfilesize.Text.ToString());
        CloudBlockBlob blob = ContainerFileTransfer.GetBlockBlobReference(downloadfile);
        var sasUrl = blob.Uri;
        CloudBlockBlob blockBlob = new CloudBlockBlob(sasUrl);
        //blobSize = Convert.ToInt32(lblfilesize.Text.ToString());
        blockSize = 4 * 1024 * 1024;
        Response.Clear();
        Response.ContentType = "APPLICATION/OCTET-STREAM";
        System.String disHeader = "Attachment; Filename=\"" + blockBlob.Name + "\"";
        Response.AppendHeader("Content-Disposition", disHeader);
       // blob.DownloadToStream(Response.OutputStream);
       // byte[] bytes = new byte[blockSize];
        for (offset = 0; offset < blobSize; offset += blockSize)
            using (var blobStream = blockBlob.OpenRead())
                if ((offset + blockSize) > blobSize)
                    blockSize = (blobSize - offset);
            byte[] buffer = new byte[blockSize];
                blobStream.Read(buffer, 0, buffer.Length);
                Response.BinaryWrite(buffer);
                Response.Flush();
        Response.End();
    SNAPSOT:
    Please suggest me if i am missing any logic.
    Pawan

  • How do I copy and paste files from a windows remote server to my mac?

    How can i copy and paste files from a remote server (windows) to my mac? i have installed cord to connect to the server but now i can´t cpy the files to my mac!

    Hi Sara.  Tanks for responding.  If I cannot figure this out (I  was up
    until 2am last night), I want to cancel my subscription.
    Here are two files you can check on/help me with.  When I try again,  it
    comes up 'an error has occurred when trying to access the service.'
    Please advise.
    Pat Tomassi
    In a message dated 11/1/2014 12:55:23 A.M. Eastern Daylight Time, 
    [email protected] writes:
    How  do I copy and paste text from a converted Word document?
    created by Sara.Forsberg (https://forums.adobe.com/people/Sara.Forsberg) 
    in Adobe Acrobat.com Services - View the full  discussion
    (https://forums.adobe.com/message/6888908#6888908)

  • Best way to make a backup of home directory and system files?

    I need to create a backup of my /home/user directory and important files like xorg.conf rc.conf & /boot/grub/menu.lst ?
    I would like to put it all into a tar file so I can keep the system on windows with out messing up the files.
    Any suggestions?

    Misfit138 wrote:
    Gen2ly wrote:
    I just did this and took notes so it might be your lucky day because I created a wiki page for it:
    Restore from Configurations
    Terrific job.
    I would suggest changing the name to "System Restore from Configuration".
    Thank you.
    Done.

Maybe you are looking for