Exctract a BLOB to file system

Hello,
I've saved some archives (PDFs, DOCs) in a BLOB Field with Initialize_Container built-in.
How could I extract these archives to file system ? (inverse operation).
Thanks. Regards.

It depends on what OLE automation interfaces Acrobat Reader supports - you may need the full version of acrobat to do any decent manipulation.

Similar Messages

  • Export BLOB to file system folder in Oracle 8i

    Hi Folks,
    I want export the doc and zip files from oracle column BLOB to folder on my desktop / network . Can anyone please suggest the easiest way .
    Thanks

    For 8i, I think you will have to rely on Java.
    http://www.oracle-base.com/articles/8i/ExportBlob.php
    For 9i and above, you can use UTL_FILE built in.
    http://www.oracle-base.com/articles/9i/ExportBlob9i.php
    Cheers
    Sarma.

  • How do you move blob content in a table out to the server file system

    Hi,
    I have a table that contains a blob column containing word and pdf documents I want to be able to take content such as a pdf held in the blob column and move a copy of the pdf to the servers file system. Can it be done.
    Thanks in anticipation.
    SDG

    There is no Monitoring SQL Activity, so we Need to find other Solutions.
    1: can be this Integration Pack:
    http://www.kelverion.com/integration_packs/ip-sql-server/
    2: Create a Trigger in SQL Side, which will Trigger a Runbook
    3: Query every ? 5 ? Minutes the Table,  compare to a sample Table and get the new Informations
    Seidl Michael | http://www.techguy.at |
    twitter.com/techguyat | facebook.com/techguyat

  • File System or BLOB

    Hi,
    I have wrote an application and all works well. I was wondering what peoples views are on the BLOB in Database vs File System argument? I have gone for the BLOB method as I like the security and ease of it. What I don't like is the more the system is used, my hosting costs begin to rise!! :(
    How is everyone else handling files in their systems? Will the introduction of APERX 4.0 with the new listener have any impact on your decision (I read it has better file handling but I have not investigated too much)?
    Just looking for a bit of guidance on which way is the Best Practise for this.
    Thanks
    Richard

    Best thing that could be said.. Read this thread on Asktom.com and your questions should be answered..:http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1011065100346196442
    Thank you,
    Tony Miller
    Webster, TX

  • Need to Move contents of BLOB from database to middle-tier file system

    I need to be able to move the contents of a BLOB (which is a PDF file) from the database to a specified location in the middle-tier file system (running 9iAS). There does not seem to be the equivalent package or other built-in functionality to DBMS_LOB (for moving INTO the database, which is amazing. Does anyone have a java bean or (?) which can accomplish this simingly simple task??

    The java bean should work to extract from the database to a binary file on either Unix or Windows. As long as the file is in .bmp format in the database, you can save the file as .bmp on you file system and everything should be alright.
    Or, perhaps, am I not understanding your question?
    Good Luck
    Eric Kamradt

  • LONG_RAW conversion (using OLE) to file system then import into BLOB column

    To whom it may concern (I will call "hero" or "savior" if you can solve this for me),
    I posted this message an another thread; but then later thought it would be better in its own thread.
    I was wondering how to extract the Adobe Acrobat Reader files (PDF) from OLE component stored in a LONG_RAW database column. I was able to successfully extract the MS-Word, MS-Excel, MS-Powerpoint, and MS-Project to the operating system. I was not able to extract the Adobe PDF files. The PDF files do not return an error message nor do they write out to the file system?
    Leonid previous posted some suggestions on how to convert the data. Can anyone expand on tasks #4 and #5 (see below)?
    You can use this library to do the following task:
    1. Get the type of an object stored inside OLE Item. Get information about the OLE server.
    GetCLSID, GetProgID, IsIDispatchSupported
    2. Get information about the object
    IsLinked, GetSourceDisplayName
    3. Get information from the object in formats supported by its IDataObject interface.
    EnumFormatEtc, RegClipFormat, GetData
    I suppose it's the best way to extract pictures!
    4. Save the object into an external file throu IPersistFile interface. It works only if IPersistFile::Save method is implemented by the OLE server. Unfortunately, some OLE servers don't support this method even don't return a correct error code.
    SaveToFile
    Works with: MS Word, MS Excel
    Not works with: Adobe Acrobat (I'm not sure. Maybe I've done something wrong), MS Photo Editor
    5. Extract the 'Contents' stream from a structured storage /a compound document/.
    ExtractToFile
    It isn't a documented way, but it can be used to extract PDF files.
    I have tried the following two scenarios for the PDF extraction:
    -- First Attempt
    ret:=OLEXTRA.SaveToFile( application, v_FILENAME_WO_EXT || '.pdf' );
    if ret <> 0 then
    show_message( 'SaveToFile Error code='||ret );
    end if;
    -- application does not return an error message
    -- application does not save the PDF file to the operating system.
    -- Second Attempt
    ret:=OLEXTRA.ExtractToFile( application, 'stg.pdf', 'fname.pdf' );
    if ret <> 0 then
    show_message( 'ExtractToFile Error code='||ret );
    end if;
    -- application does not return an error message.
    -- application does not save fname.pdf to the operating system
    -- application saves the stg.pdf to file system, but cannot open in Adobe
    Thanks in advance for the help,
    Mike

    There is no way from PL/SQL in Forms - you'll have to call out to C or Java Code to do it.
    You can link in Pro*C or OCI code into forms as a user exit in which case it can share the forms connection but that's not for the faint hearted.
    Using Java - called from the Java Importer feature in 6i+ you'll end up creating a separate connection.
    Frankly if you can do it in a generic enough way through a VB executable stick with that.
    Forms can get images in an out of a long raw using read_image_file and write_image_file but that does not extend to any binary file - just images.

  • Store \ Retrieve files from file system

    Hi to all!
    I would like to implement a solution for storing files uploaded via apex user interface to servers file system. As well I would like this files to be retrievable by apex users. I designed the following solution:
    For upload:
    1. Through file browse item user chooses file to be uploaded
    2. File goes to custom table (as BLOB)
    -- so far i would use apex Upload\Download files tutorial
    3. File(BLOB) would then have to be written to file system to some directory and file id would have to be written to some db table which holds pointers to files on file system
    4. delete file(blob) from custom table (from step 2)
    For download:
    1. user chooses link from some report region(based on table giving file pointers to files residing on file system)
    2. file identified with chosen file pointer is then inserted into blob column of some custom table in db
    3. from custom table with download procedure fie is finally presented to user
    4. delete file(blob) from custom table (from step 2)
    Using apex tutorial for Upload\Download files it is straitforward to get the files from db table or into db table using blobs. But i have not seen any example of using BFILE or migrating files from db to file system and vice versa.
    So some Q arise:
    a) How can I implement step 3 under For upload section above
    b) How can I implement step 2 under For download section above
    c) Is there any way to directly upload file to file system via apex user interface or to directly download file from file system via some report region link column?
    Please help!!!
    Regards Marinero
    Message was edited by:
    marinero

    marinero,
    Here is a procedure that will copy an uploaded file to the file system:
      Procedure BLOB_TO_FILE(p_file_name In Varchar2) Is
        l_out_file    UTL_FILE.file_type;
        l_buffer      Raw(32767);
        l_amount      Binary_Integer := 32767;
        l_pos         Integer := 1;
        l_blob_len    Integer;
        p_data        Blob;
        file_name  Varchar2(256);
      Begin
        For rec In (Select ID
                              From HTMLDB_APPLICATION_FILES
                             Where Name = p_file_name)
        Loop
            Select BLOB_CONTENT, filename Into p_data, file_name From HTMLDB_APPLICATION_FILES Where ID = rec.ID;
            l_blob_len := DBMS_LOB.getlength(p_data);
            l_out_file := UTL_FILE.fopen('UPDOWNFILES_DIR', file_name, 'wb', 32767);
            While l_pos < l_blob_len
            Loop
              DBMS_LOB.Read(p_data, l_amount, l_pos, l_buffer);
              If l_buffer Is Not Null Then
                UTL_FILE.put_raw(l_out_file, l_buffer, True);
              End If;
              l_pos := l_pos + l_amount;
            End Loop;
            UTL_FILE.fclose(l_out_file);
        End Loop;         
      Exception
        When Others Then
          If UTL_FILE.is_open(l_out_file) Then
            UTL_FILE.fclose(l_out_file);
          End If;
      end; And here is a procedure that will download a file directly from the file system:
      Procedure download_my_file(p_file In Number) As
        v_length    Number;
        v_file_name Varchar2(2000);
        Lob_loc     Bfile;
      Begin
        Select file_name
          Into v_file_name
          From UpDownFiles F
         Where File_id = p_file;
        Lob_loc  := bfilename('UPDOWNFILES_DIR', v_file_name);
        v_length := dbms_lob.getlength(Lob_loc);
        owa_util.mime_header('application/octet', False);
        htp.p('Content-length: ' || v_length);
        htp.p('Content-Disposition: attachment; filename="' || SUBSTR(v_file_name, INSTR(v_file_name, '/') + 1) || '"');
        owa_util.http_header_close;
        wpg_docload.download_file(Lob_loc);
      End download_my_file;I could put a sample application on apex.oracle.com, but it wouldn't be able to access the file system on that server.

  • How to insert a JPG file from file system to Oracle 10g?

    I have developed a schema to store photos as BLOB which store the text description as CLOB original filename, file size.
    I also use ctxsys.context to index TEXT_DESCRIPTION in order to perform Oracle Text Search and it works.
    I would like to insert some JPG file from say C:\MYPHOTO\Photo1.jpg as a new record. How can I do this in SQL PLus and/or Loader?
    How can I retrieve the PHOTO_IMAGE back to the file system using SQL Plus and/or command line in DOS?
    See the following script:
    create user myphoto identified by myphoto;
    grant connect, resource, ctxapp to myphoto;
    connect myphoto/myphoto@orcl;
    PROMPT Creating Table PHOTOS
    CREATE TABLE PHOTOS
    (PHOTO_ID VARCHAR2(15) NOT NULL,
    PHOTO_IMAGE BLOB,
    TEXT_DESCRIPTION CLOB,
    FILENAME VARCHAR2(50),
    FILE_SIZE NUMBER NOT NULL,
    CONSTRAINT PK_PHOTOS PRIMARY KEY (PHOTO_ID)
    create index idx_photos_text_desc on
    PHOTOS(TEXT_DESCRIPTION) indextype is ctxsys.context;
    INSERT INTO PHOTOS VALUES
    ('P00000000000001', empty_blob(), empty_clob(),
    'SCGP1.JPG',100);
    INSERT INTO PHOTOS VALUES
    ('P00000000000002', empty_blob(), 'Cold Play with me at the concert in Melbourne 2005',
    'COLDPLAY1.JPG',200);
    INSERT INTO PHOTOS VALUES
    ('P00000000000003', empty_blob(), 'My parents in Melbourne 2001',
    'COLDPLAY1.JPG',200);
    EXEC CTX_DDL.SYNC_INDEX('idx_photos_text_desc');
    SELECT PHOTO_ID ,TEXT_DESCRIPTION
    FROM PHOTOS;
    SELECT score(1),PHOTO_ID ,TEXT_DESCRIPTION
    FROM PHOTOS
    WHERE CONTAINS(TEXT_DESCRIPTION,'parents',1)> 0
    ORDER BY score(1) DESC;
    SELECT score(1),PHOTO_ID ,TEXT_DESCRIPTION
    FROM PHOTOS
    WHERE CONTAINS(TEXT_DESCRIPTION,'cold play',1)> 0
    ORDER BY score(1) DESC;
    SELECT score(1),score(2), PHOTO_ID ,TEXT_DESCRIPTION
    FROM photos
    WHERE CONTAINS(TEXT_DESCRIPTION,'Melbourne',1)> 0
    AND CONTAINS(TEXT_DESCRIPTION,'2005',2)> 0
    ORDER BY score(1) DESC;

    Hi
    You can use the following to insert an image:
    create table imagetab(id number primary key,imagfile blob, fcol varchar2(10));
    create or replace directory imagefiles as 'c:\'
    declare
        v_bfile BFILE;
        v_blob  BLOB;
      begin
        insert into imagetab (id,imagfile,fcol)
        values (3,empty_blob(),'BINARY')
        return imagfile into v_blob;
        v_bfile := BFILENAME ('IMAGEFILES', 'MyImage.JPG');
        Dbms_Lob.fileopen (v_bfile, Dbms_Lob.File_Readonly);
        Dbms_Lob.Loadfromfile (v_blob, v_bfile, Dbms_Lob.Getlength(v_bfile));
        Dbms_Lob.Fileclose(v_bfile);
        commit;
      end;
    /

  • Uploaded Files stored in Oracle 10G database or in Unix File system

    Hey All,
    I am trying to understand best practices on storing uploaded files. Should you store within the database itself (this is the current method we are using by leveraging BLOB storage) or use a BFILE locator to use the files system storage (we have our DB's on UNIX) . . .or is there another method I should be entertaining? I have read arguments on both sides of this question. I wanted to see what answers forum readers could provide!! I understand there are quite a few factors but the situation I am in is as follows:
    1) Storing text and pdf documents.
    2) File sizes range from a few Kb to up to 15MB in size
    3) uploaded files can be deleted and updated / replaced quite frequently
    Right now we have an Oracle stored procedure that is uploading the files binary data into a BLOB column on our table. We have no real "performance" problems with this method but are entertaining the idea of using the UNIX file system for storage instead of the database.
    Thanks for the insight!!
    Anthony Roeder

    Anthony,
    First word you must learn here in this forum is RESPECT.
    If you require any further explanation, just say so.
    BLOB compared with BFILE
    Security:
    BFILEs are inherently insecure, as insecure as your operating system (OS).
    Features:
    BFILEs are not writable from typical database APIs whereas BLOBs are.
    One of the most important features is that BLOBs can participate in transactions and are recoverable. Not so for BFILEs.
    Performance:
    Roughly the same.
    Upping the size of your buffer cache can make a BIG improvement in BLOB performance.
    BLOBs can be configured to exist in Oracle's cache which should make repeated/multiple reads faster.
    Piece wise/non-sequential access of a BLOB is known to be faster than a that of a BFILE.
    Manageability:
    Only the BFILE locator is stored in an Oracle BACKUP. One needs to do a separate backup to save the OS file that the BFILE locator points to. The BLOB data is backed up along with the rest of the database data.
    Storage:
    The amount of table space required to store file data in a BLOB will be larger than that of the file itself due to LOB index which is the reason for better BLOB performance for piece wise random access of the BLOB value.

  • STORE A COMPLETE FILE SYSTEM IN THE DATABASE 11GR2

    Hi everyone
    I have the following issue:
    I tried to store in an oracle database TABLE the completre file structure
    of a file system that includes the follwing:
    -Name of the file
    -Date of last modification
    -Location
    -The entire content of the phisical file BLOB datatype
    I have the following piece of code to archieve this, but i still have a
    problem...
    When i tried to add the records to the database by implememting all
    the connecttions stuffs, oracle and java classes required the program
    inserts a FEW RECORDS and after that:
    ¡¡¡hangs up!!!.
    The main problem is that i cant release the connection and get another new when i using
    JDBC POOL so the server full their available connections.
    Please tell me what is the best approach or programming practice on order to
    meet this goal.
    Thanks from Colombia - Latin America..
    HERE IS THE CODE:
    import java.io.* ;
    * A simple class to demonstrate a recursive directory traversal
    * in Java.
    * Error handling was left out to make the code easier to understand.
    * In production code, you should check if the arguments from the
    * command line are really file files or directories.
    public class RecursiveTraversal
    * Works on a single file system entry and
    * calls itself recursively if it turns out
    * to be a directory.
    * @param file A file or a directory to process
    public void traverse( File file )
    // Print the name of the entry
    //System.out.println( file ) ;
    // Check if it is a directory
    if( file.isDirectory() )
    // Get a list of all the entries in the directory
    String entries[] = file.list() ;
    // Ensure that the list is not null
    if( entries != null )
    // Loop over all the entries
    for( String entry : entries )
    // Recursive call to traverse
    traverse( new File(file,entry) ) ;
    else
    if(file.isFile())
    System.out.println( file.getParent() ) ;
    System.out.println( file.getName() ) ;
    else
    System.out.println("*** WRONG VALUE ***");
    * The program starts here.
    * @param args The arguments from the command line
    public static void main( String args[] )
    // Create an object of this class
    RecursiveTraversal rt = new RecursiveTraversal() ;
    if( args.length == 0 )
    // If there are no arguments, traverse the current directory
    rt.traverse( new File(".") ) ;
    else
    // Else process every argument sequentially
    for( String arg : args )
    rt.traverse( new File(arg) ) ;
    }

    Thanks for the reply, the implementation that you refer is useful for another type of application i need to stored the file system in a TABLE of a database
    in order to make a part of an information system integration and can use SQL statements to acomplish this.
    I follow the recomendation and post it in the SQL/JDBC forum because when i try to release de active connection i can't acomplish this.
    And i need to know how to use JDBC connection poolling to open a connection just once, release and use it again.

  • Store large volume of Image files, what is better ?  File System or Oracle

    I am working on a IM (Image Management) software that need to store and manage over 8.000.000 images.
    I am not sure if I have to use File System to store images or database (blob or clob).
    Until now I only used File System.
    Could someone that already have any experience with store large volume of images tell me what is the advantages and disadvantages to use File System or to use Oracle Database ?
    My initial database will have 8.000.000 images and it will grow 3.000.000 at year.
    Each image will have sizes between 200 KB and 8 MB, but the mean is 300 KB.
    I am using Oracle 10g I. I read in others forums about postgresql and firebird, that isn't good store images on database because always database crashes.
    I need to know if with Oracle is the same and why. Can I trust in Oracle for this large service ? There are tips to store files on database ?
    Thank's for help.
    Best Regards,
    Eduardo
    Brazil.

    1) Assuming I'm doing my math correctly, you're talking about an initial load of 2.4 TB of images with roughly 0.9 TB added per year, right? That sort of data volume certainly isn't going to cause Oracle to crash, but it does put you into the realm of a rather large database, so you have to be rather careful with the architecture.
    2) CLOBs store Character Large OBjects, so you would not use a CLOB to store binary data. You can use a BLOB. And that may be fine if you just want the database to be a bit-bucket for images. Given the volume of images you are going to have, though, I'm going to wager that you'll want the database to be a bit more sophisticated about how the images are handled, so you probably want to use [Oracle interMedia|http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14302/ch_intr.htm#IMURG1000] and store the data in OrdImage columns which provides a number of interfaces to better manage the data.
    3) Storing the data in a database would generally strike me as preferrable if only because of the recoverability implications. If you store data on a file system, you are inevitably going to have cases where an application writes a file and the transaction to insert the row into the database fails or a the transaction to delete a row from the database succeeds before the file is deleted, which can make things inconsistent (images with nothing in the database and database rows with no corresponding images). If something fails, you also can't restore the file system and the database to the same point in time.
    4) Given the volume of data you're dealing with, you may want to look closely at moving to 11g. There are substantial benefits to storing large objects in 11g with Advanced Compression (allowing you to compress the data in LOBs automatically and to automatically de-dupe data if you have similar images). SecureFile LOBs can also be used to substantially reduce the amount of REDO that gets generated when inserting data into a LOB column.
    Justin

  • Upload file in to file system using Apex

    Hi...
    I have tried UTL_FILE to upload file in Directory. But First i have to upload file in Table in BLOB datatype and then copy it to file system using BFILE.
    I have to store files in file system as per requirements.
    I want to upload file directly to File System. Suggest me the right way...
    Thank You in advance........
    Edited by: user639262 on Aug 28, 2008 2:11 PM

    Apex only supports upload into a table.
    If you want to upload directly to the file system you should look into the possibilities of your application server. Maybe you could find a piece of code in Java or PHP that performs an upload.
    good luck, DickDral

  • Procedure to Insert PDF from FIle System to Database

    Hi ,
    I have a requirement to put the pdf files from our Local Machine or File system into Database table ..
    For that I have created a directory called "MY_PDF" with create and replace directory .
    Also , I have created a database table to store the files from Local machine FIle System directory ( MY_PDF) .
    I have created a procedure which takes 2 inputs ( ID and FIlename ) as parameters , this procedure when executes , it insert the file along with the ID in the database table .
    Procedure is as follows :
    CREATE OR REPLACE PROCEDURE proc_load_a_file( p_id IN NUMBER, p_filename IN VARCHAR2 )
    AS
    l_blob BLOB;
    l_bfile BFILE;
    x VARCHAR2(1000);
    BEGIN
    x:=p_filename;
    INSERT INTO demo(id,theblob,filename) VALUES ( p_id, empty_blob() ,x)
    RETURNING theBlob INTO l_blob;
    UPDATE demo
    SET locater =l_blob where id=p_id;
    l_bfile := bfilename( 'MY_FILES', p_filename );
    DBMS_LOB.FILEOPEN( l_bfile );
    DBMS_LOB.LOADFROMFILE( l_blob, l_bfile,
    DBMS_LOB.getlength( l_bfile ) );
    DBMS_LOB.fileclose( l_bfile );
    COMMIT;
    END;
    Now , my requirement is not to insert one one file each and every time when I execute the procedure .
    My requirement is first to check the File system Directory (MY_PDF) . If
    there is any pdf file in the directory then it will call that procedure and insert that file into the database untill no files found in the dorectory ( MY_PDF) .
    I am not getting the idea how to do this ..
    Please someone provide some valueable inputs .. so that I can finish it up .
    Thanks
    Prashant Dwivedi

    Suggest using the FlowElement.setStyle method to attach additional information about the image to the InlineGraphicElement that gets created.  Looking at the example code in the posted link you'll need to pass that data to the imageLoadComplete method.  The InlineGraphicElement can be found by saving interactionManager.absoluteStart before the graphic is inserted and then calling textFlow.findLeaf(savedAbsoluteStart).
    Hope that helps,
    Richard

  • Can you upload to a file system directly and not to wwv_flow_file_objects$

    The following link shows how to upload a file. These files that are uploaded are stored in a table called wwv_flow_file_objects$ .
    However what if I want to upload a file but save it to the file system (share) and not put it into wwv_flow_file_objects$ is that possible
    http://download.oracle.com/docs/cd/B31036_01/doc/appdev.22/b28839/up_dn_files.htm#CJAHDJDA
    When you use the file upload item type, the files you upload are stored in a table called wwv_flow_file_objects$

    It has to be loaded to wwv_flow_file_objects$, but you can use the
    UTL_FILE package to write it to a directory the database has access to. Use FOPEN with open_mode wb and use the PUT_RAW procedure to write into the file. Use READ procedure of the DBMS_LOB package to read your BLOB in junks.
    UTL_FILE: http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/u_file.htm#i1003526
    DBMS_LOB: http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_lob.htm#i999170
    I think that should work.
    Patrick
    My APEX Blog: http://inside-apex.blogspot.com
    The ApexLib Framework: http://apexlib.sourceforge.net
    The APEX Builder Plugin: http://sourceforge.net/projects/apexplugin/

  • Uploading file in file system or inserting it in database?

    Dear All,
    I am developing an application which will upload the files and store the information about file in database.
    I have a question that which is good practice?
    Uploading file in hard disk of server or inserting the file in database as BLOB?
    File size varies from 1 MB to 100 MB.
    Please suggest me good idea.

    malcolmmc wrote:
    The advantage of using a BLOB is that you can then access the file data from anywhere you can access the database, whereas a file path may be different from another client machine, or the file may be inaccessible.Another advantage is data integrity. I've encountered scenarios where file refernces in a database became invalid because an overzealous sys-admin deleted the files as stale after they'd reached a set age.
    Or someone decides to "restructure the file system" and the entire directory containing your files gets moved somewhere else (hopefully not to /dev/null).
    If the files are stored on different machines from the database the risk of this happening increases exponentially, if those machines are maintained by another company/department from the DBAs it goes through the roof.

Maybe you are looking for