UTL_COMPRESS Zipping Multiple BLOBs

Hey everyone, I'm having trouble figuring out how to use UTL_COMPRESS.
What I want to do is take several BLOBs from one table, and put them into one zip file. Can anyone show me an example of where this is done?
Here is some sample code of what I have so far:
My table:
CREATE TABLE  "FILES"
   (     "FILE_ID" NUMBER,
     "FILE_TYPE" NUMBER,
     "FILENAME" VARCHAR2(1000),
     "DATE_ADDED" DATE,
     "ADDED_BY" VARCHAR2(255),
     "FILE_BLOB" BLOB,
/Some sample code:
DECLARE
  b_dl_file1 BLOB;
  b_dl_file2 BLOB;
  b_dl_file3 BLOB;
  b_compressed_file BLOB;
BEGIN
select FILE_BLOB
into b_dl_file1
from FILES
where FILE_ID = 64;
select FILE_BLOB
into b_dl_file2
from FILES
where FILE_ID = 65;
select FILE_BLOB
into b_dl_file3
from FILES
where FILE_ID = 66;
b_compressed_file := UTL_COMPRESS.LZ_COMPRESS(b_dl_file1);
END;So what I've posted works fine, it compresses a single file. What I want is to take all three of those blobs (for example) and add them to one zip file. I've looked into using UTL_COMPRESS.LZ_COMPRESS_ADD, but as far as I can see, that only takes RAW data. Will I have to break my BLOBs into RAW strings and then compress those? Will that even work?
Any help would be appreciated!

Wow! Thanks! That's exactly what I'm looking for. I'm having some trouble getting this code to run though, I'm recieving the following error:
"ORA-06502: PL/SQL: numeric or value error: invalid LOB locator specified: ORA-22275 "
I've been debugging and it looks like its coming from the add1file procedure.
I modified the code a bit to make it into a package:
CREATE OR REPLACE PACKAGE zip_blobs AS
  /*Package written by Anton Scheffer, used with permission*/
  PROCEDURE add1file(p_zipped_blob in out blob, p_name in varchar2, p_content in blob);
  PROCEDURE finish_zip(p_zipped_blob in out blob);
  PROCEDURE save_zip(p_zipped_blob in blob, p_dir in varchar2, p_filename in varchar2);
END zip_blobs;
CREATE OR REPLACE PACKAGE BODY zip_blobs AS
  function little_endian( p_big in number, p_bytes in pls_integer := 4 )
  return raw
  is
  begin
    return utl_raw.substr( utl_raw.cast_from_binary_integer( p_big, utl_raw.little_endian ), 1, p_bytes );
  end;
  procedure add1file
    ( p_zipped_blob in out blob
    , p_name in varchar2
    , p_content in blob
  is
    t_now date;
    t_blob blob;
    t_clen integer;
  begin
    t_now := sysdate;
    t_blob := utl_compress.lz_compress( p_content );
    t_clen := dbms_lob.getlength( t_blob );
    if p_zipped_blob is null
    then
      dbms_lob.createtemporary( p_zipped_blob, true );
    end if;
    dbms_lob.append( p_zipped_blob
                   , utl_raw.concat( hextoraw( '504B0304' ) -- Local file header signature
                                   , hextoraw( '1400' )     -- version 2.0
                                   , hextoraw( '0000' )     -- no General purpose bits
                                   , hextoraw( '0800' )     -- deflate
                                   , little_endian( to_number( to_char( t_now, 'ss' ) ) / 2
                                                  + to_number( to_char( t_now, 'mi' ) ) * 32
                                                  + to_number( to_char( t_now, 'hh24' ) ) * 2048
                                                  , 2
                                                  ) -- File last modification time
                                   , little_endian( to_number( to_char( t_now, 'dd' ) )
                                                  + to_number( to_char( t_now, 'mm' ) ) * 32
                                                  + ( to_number( to_char( t_now, 'yyyy' ) ) - 1980 ) * 512
                                                  , 2
                                                  ) -- File last modification date
                                   , dbms_lob.substr( t_blob, 4, t_clen - 7 )         -- CRC-32
                                   , little_endian( t_clen - 18 )                     -- compressed size
                                   , little_endian( dbms_lob.getlength( p_content ) ) -- uncompressed size
                                   , little_endian( length( p_name ), 2 )             -- File name length
                                   , hextoraw( '0000' )                               -- Extra field length
                                   , utl_raw.cast_to_raw( p_name )                    -- File name
    dbms_lob.append( p_zipped_blob, dbms_lob.substr( t_blob, t_clen - 18, 11 ) );     -- compressed content
    dbms_lob.freetemporary( t_blob );
  end;
  procedure finish_zip( p_zipped_blob in out blob )
  is
    t_cnt pls_integer := 0;
    t_offs integer;
    t_offs_dir_header integer;
    t_offs_end_header integer;
    t_comment raw(32767) := utl_raw.cast_to_raw( 'Implementation by Anton Scheffer' );
  begin
    t_offs_dir_header := dbms_lob.getlength( p_zipped_blob );
    t_offs := dbms_lob.instr( p_zipped_blob, hextoraw( '504B0304' ), 1 );
    while t_offs > 0
    loop
      t_cnt := t_cnt + 1;
      dbms_lob.append( p_zipped_blob
                     , utl_raw.concat( hextoraw( '504B0102' )      -- Central directory file header signature
                                     , hextoraw( '1400' )          -- version 2.0
                                     , dbms_lob.substr( p_zipped_blob, 26, t_offs + 4 )
                                     , hextoraw( '0000' )          -- File comment length
                                     , hextoraw( '0000' )          -- Disk number where file starts
                                     , hextoraw( '0100' )          -- Internal file attributes
                                     , hextoraw( '2000B681' )      -- External file attributes
                                     , little_endian( t_offs - 1 ) -- Relative offset of local file header
                                     , dbms_lob.substr( p_zipped_blob
                                                      , utl_raw.cast_to_binary_integer( dbms_lob.substr( p_zipped_blob, 2, t_offs + 26 ), utl_raw.little_endian )
                                                      , t_offs + 30
                                                      )            -- File name
      t_offs := dbms_lob.instr( p_zipped_blob, hextoraw( '504B0304' ), t_offs + 32 );
    end loop;
    t_offs_end_header := dbms_lob.getlength( p_zipped_blob );
    dbms_lob.append( p_zipped_blob
                   , utl_raw.concat( hextoraw( '504B0506' )                                    -- End of central directory signature
                                   , hextoraw( '0000' )                                        -- Number of this disk
                                   , hextoraw( '0000' )                                        -- Disk where central directory starts
                                   , little_endian( t_cnt, 2 )                                 -- Number of central directory records on this disk
                                   , little_endian( t_cnt, 2 )                                 -- Total number of central directory records
                                   , little_endian( t_offs_end_header - t_offs_dir_header )    -- Size of central directory
                                   , little_endian( t_offs_dir_header )                        -- Relative offset of local file header
                                   , little_endian( nvl( utl_raw.length( t_comment ), 0 ), 2 ) -- ZIP file comment length
                                   , t_comment
  end;
  procedure save_zip
    ( p_zipped_blob in blob
    , p_dir in varchar2
    , p_filename in varchar2
  is
    t_fh utl_file.file_type;
    t_len pls_integer := 32767;
  begin
    t_fh := utl_file.fopen( p_dir, p_filename, 'wb' );
    for i in 0 .. trunc( ( dbms_lob.getlength( p_zipped_blob ) - 1 ) / t_len )
    loop
      utl_file.put_raw( t_fh, dbms_lob.substr( p_zipped_blob, t_len, i * t_len + 1 ) );
    end loop;
    utl_file.fclose( t_fh );
  end;
END zip_blobs;My code:
DECLARE
  b_dl_file1 BLOB;
  b_dl_file2 BLOB;
  b_dl_file3 BLOB;
  b_zipped_blob BLOB;
BEGIN
  select FILE_BLOB
  into b_dl_file1
  from FILES
  where FILE_ID = 64;
  select FILE_BLOB
  into b_dl_file2
  from FILES
  where FILE_ID = 65;
  select FILE_BLOB
  into b_dl_file3
  from FILES
  where FILE_ID = 66;
  zip_blobs.add1file(b_zipped_blob, 'test1.bin', b_dl_file1);
  zip_blobs.add1file(b_zipped_blob, 'test2.bin', b_dl_file2);
  zip_blobs.add1file(b_zipped_blob, 'test3.bin', b_dl_file3);
  zip_blobs.finish_zip(b_zipped_blob);
  insert into compressed_files(compressed_blob) values(b_zipped_blob);
END;So I'm inserting it into a table, but even when I use save_zip, I get the same error. I tried playing around with freeing p_zipped_blob and not freeing t_blob, but it didn't seem to work, and I'm not seeing where else it could be going wrong. Any more help would be awesome!
Thanks!

Similar Messages

  • How do i insert multiple blob files in Stored procedure using c#?

    i want to add multiple blob files to a stored procedure at one go.Thus i have a 2 dimensional byte array consisting of multiple blob files.How to i add this 2 dimensional array to stored procedure?

    Hi Jeff,
    I haven't tried to insert multiple images at a time, but have done it for single image at a time and composed article on it : BizTalk
    Server 2010: How to Insert Image In SQL Through Orchestration and sample can be found at : 
    BizTalk Server 2010: How to Insert
    Image In SQL Through Orchestration sample.
    I hope it helps.
    Maheshkumar S Tiwari|User
    Page | http://tech-findings.blogspot.com/

  • Manage multiple blob in wizard

    Hi all,
    i need to temporarily store multiple blob files during a wizard before to save in tables, but a collection has only one blob attribute, so is there another way to create my wizard?
    Thanks,
    Sergio

    Hi,
    But you can have multiple rows in apex_collection.
    Create own collection for blob, and insert as many row you like.
    If you need link blob data to other collection data, use other collection columns
    Regards,
    Jari

  • Writing multiple BLOB (PDF) records into one PDF file

    I currently have a procedure that writes an individual BLOB pdf row and outputs it to a PDF file, however I would like to write multiple BLOB rows into one PDF.
    Oracle version:10g R2.
    Does anyone know whether it is possible to do this?
    Here is my code, I was hoping to use a cursor FOR LOOP to read the BLOB records. The BLOB records do successfully load into a new PDF file, however when you open it the PDF only the first page is viewable. I am assuming the issue is to do with the PDF format rather than writing the data out to the file. I.e. the Page numbers etc.., incorrect formatting of the PDF?
    declare
    -- Test statements here
    b BLOB;
    amount BINARY_INTEGER;
    file_handle UTL_FILE.FILE_TYPE;
    l_pos INTEGER := 1;
    l_blob_len INTEGER;
    l_buffer RAW (32767);
    l_amount BINARY_INTEGER := 32767;
    file_name_ VARCHAR2(200);
    pattern_id_ VARCHAR2(200) := '5555555';
    pdf_path_ VARCHAR2(200) := 'PDF_OUT';
    cursor get_blob_recs is
    select pdf from mds_remote_pdf_tmp;
    BEGIN
    file_name_ := to_char(pattern_id_)||'.PDF';
    file_handle := UTL_FILE.FOPEN(pdf_path_,file_name_,'wb');
    FOR rec_ IN get_blob_recs LOOP
    l_blob_len := DBMS_LOB.getlength (rec_.pdf);
    l_pos := 1;
    WHILE l_pos < l_blob_len
    LOOP
    DBMS_LOB.READ (rec_.pdf, l_amount, l_pos, l_buffer);
    UTL_FILE.put_raw (file_handle, l_buffer, FALSE);
    l_pos := l_pos + l_amount;
    END LOOP;
    END LOOP;
    UTL_FILE.FCLOSE(file_handle);
    end;
    Any advice would be greatly appreciated.
    Regards,
    David.

    I guessed there was more to a PDF file format than just amending the BLOB objects!. I think I'll have to create a function with an IN param containing the PDF file list, and invoke a Java class to merge the PDFs in the OS.
    My requirement is to record the history of when a hand written form was completed. E.g. a user might complete half a document one day, and the rest of the document another day, therefore I want one PDF with two pages of the same form at different stages of completion. These forms are currently being created as two separate PDFs, and the problem is I am restricted to displaying only one PDF!
    Thank you.
    David.
    Edited by: david.massey on Jan 26, 2011 8:16 AM

  • Archiving multiple blobs - wpg_docload.download_file ( l_blob )

    I am using the standard wpg_docload.download_file ( l_blob ) to download individual files in APEX.
    However I also need an Archive function to pull out multiple blob records each time from the Oracle database and I do not want to select "save as" each time for each file. As this is the case then I cannot use
    wpg_docload.download_file( l_blob )
    Is there an alternative command I can use to export multiple blob files from oracle to a specific folder on the network
    Thanks
    Stephen

    Stephen:
    if you ever figure out how to do this, please make sure you post the solution on this forum. We have the same requirement, to be used for 2 scenarios: one for archiving old documents, and the other for downloading a bunch of files based on the report search criteria (e.g. download me all policy documents issued in 2007 calendar year, download all certificates issued in county XYZ, etc).
    Vojin

  • Multiple Blob downloads in one report cell

    Hi all,
    I want to create an interactive report. This report is based on 2 tabled that are joined. one table has topics in it the other documents attached to the topics.
    the problem i'm facing is that a topic can have multiple docs attached to it.
    At this moment (Only one doc per topic) I don't have a problem to create the download link to this BLOB using the dbms_lob.getlength.
    Since there could be more documents attached to one topic it is impossible to me to show all the download links in the same row.
    I tried creating my own HTML table with the DBMS_LOB.getlength in separate rows but it doesn't work because it has to be a number and when I do that it is a string.
    Does anybody have an idea on how to solve this? Maybe creating some sort of report in my report but I don't know how to do this.
    Thanks
    Steven

    Steven,
    I haven't done it before and am not 100% sure it will work but how about writing a function that uses the pl/sql method of retrieving blobs where the function reads all the topics and puts them into one string that you return (just using a pl/sql loop). Then you can call that function from your report.
    -- Sharon

  • Zipping multiple Payloads to single Zipfile using payLoadZipBean

    Dear Friends,
    Can you help me in doing this sceanrios:
    I'm trying to send multiple payloads from source (selection
    of multiple payloads is done by checking Advance selection for
    Source file)  to PI, that inturn Zip all Payloads in to a single Zip FIle.
    (note: payLoadZipBean is giving individual zip file for every single payload but I want it all in single Zip file)
    And also can I zip, Additional Files sent through File Adapter,
    as these are not considered as payloads. Plz correct me If I'm wrong.
    I request you plz dont paste any links to blogs or forums.
    I'm trying to create a module to perform this scenario,plz suggest me better answers, in case module develpment is not required.
    Dear Stefen, I hope I will get a good answer from you soon.
    And thanks for suggesting me to post a thread for this issue.
    Thanks in advance
    Praveen K Kurni

    Dear Sameer,
    I did studied the SAP note;
    By using these parameters
    Module Key: zip
    Parameter name: zip.mode
    Parameter value: zipAll
    Module Key: zip
    Parameter name: zip.filenameKey
    Parameter value: contentType
    Module zips all payloads as individual zipfiles
    for ex:
    my files are:
    1. abc1.xml
    2. abc2.xml
    3. abc3.xml
    module payLoadZipBean zips these payloads as
    1. abc1.zip
    2. abc2.zip
    3. abc3.zip
    But I want all the files to be zipped in to single zipped file:
    let say abc_all.zip
    Thanks any way
    Praveen K Kurni

  • How to zip multiple files using plsql

    Hi All,
    I have created a group of files using utl_file and stored in a specific directory.
    I want to zip them all so that i can send it throug email.
    Could you please help me to write a pl sql program which can do the above.
    Thanks
    Kiran

    Hello Kiran,
    you posted this question before {thread:id=2248112} and got some answers. Did you follow the links? If you have still questions then please use the original thread.
    Regards
    Marcus

  • Zip multiple files or folders but keep the file name

    These two example files need to be compressed into one zip
    20150113-Signs-R04.eps
    20150113-Signs-R04.jpg
    As you know the the default name of the zip becomes:
    Archive.zip
    I would like it to be:
    20150113-Signs-R04.zip
    I understand the ZIP utility cannot do this. However, I was hoping there is an Applescript that would help me get it done.

    This Automator Workflow should do what you want.
    (You can also save as an Automator Service (delete the Ask for Finder Items Action) that you can access by selecting files in Finder then right click):
    mv "$1" "${2%.*}".zip

  • Zipping Multiple files

    Hi All,
    I need to Zip text , csv and pdf files. Can i hav some inputs for the same plz.
    Reg,
    Monish

    chk these links
    /people/stefan.grube/blog/2007/02/20/working-with-the-payloadzipbean-module-of-the-xi-adapter-framework
    http://help.sap.com/saphelp_nw04/helpdata/en/45/da9358a1772e97e10000000a155369/content.htm
    refer this note
    https://service.sap.com/sap/support/notes/965256
    Regards,
    Syed

  • Email Clob values using zip.

    I have table cms_reports. Tbl srtucture group id number data type file is clob datatype
    group_id File (clob) Filename(varchar2)
    1 clobdata(1) file1
    1 clobdata(2) file2
    1 clobdata(3) file3
    1 clobdata(4) file4
    2 clobdata(5) file5
    2 clobdata(6) file6
    I have to write a procedure that takes group id as IN parameter
    if I pass 1 as group id to the procedure, proc can zip file1,file2,file3 and file4, then send an email.
    file1 should hold clobdata(1)
    file2 should hold clobdata(2)
    file3 should hold clobdata(3)
    file4 should hold clobdata(4)
    is it possible or any suggestions?

    Anton,
    I think , I will convert all the clobs to blobs, then I will use your package to zip multiple blobs to one zip file.
    I am using this below code to convet the clob to blob and then pass it to your package code. am I doing right thing?
    CREATE OR REPLACE FUNCTION f_clob_to_blob(p_clob IN CLOB) RETURN BLOB IS
    v_blob BLOB;
    v_offset NUMBER DEFAULT 1;
    v_amount NUMBER DEFAULT 4096;
    v_offsetwrite NUMBER DEFAULT 1;
    v_amountwrite NUMBER;
    v_buffer VARCHAR2(4096 CHAR);
    BEGIN
    dbms_lob.createtemporary(v_blob, TRUE);
    Begin
    LOOP
    dbms_lob.READ(p_clob, v_amount, v_offset, v_buffer);
    v_amountwrite := utl_raw.length(utl_raw.cast_to_raw(v_buffer));
    dbms_lob.WRITE(v_blob, v_amountwrite, v_offsetwrite, utl_raw.cast_to_raw(v_buffer));
    v_offsetwrite := v_offsetwrite + v_amountwrite;
    v_offset := v_offset + v_amount;
    v_amount := 4096;
    END LOOP;
    EXCEPTION
    WHEN no_data_found THEN
    NULL;
    End;
    RETURN v_blob;
    END f_clob_to_blob;
    /

  • Multiple CLOB/BLOB

    Hi there,
    I'm looking for the way how to make multiple insert/update on a table with multiple CLOB/BLOB fields using Objects for OLE for C++. When I looked into samples, there is only single insert (of one CLOB). This, in turn, a provided sample will only over-write first inserted LOB with data that becomes to the last inserted row (and last column).
    Thanks in advance for any comment back.
    Nguyen Duy Hoa.

    Hi,
    See the sample BLOBs at the site http://www.geocities.com/oledbpro/docs/examples/blobs.htm, which tells you how to deal with multiple BLOBs/CLOBs etc within a rowset using OleDBPro.
    Yuancai (Charlie) Ye
    See 30 real well-tested advanced OLEDB samples
    Use of free SocketPro for creating super client and server application with numerous samples
    www.udaparts.com

  • Java - Zipping BLOB

    I have a table annotations (ann_annotation BLOB) which is becoming too large. That's why we opted for zipping the contents. For this purpose I have created (on Oracle 10i, JVM 1.5) 2 java-methods as follows:
    CREATE OR REPLACE JAVA SOURCE NAMED "ZipHandler" AS
    import java.lang.*;
    import java.sql.*;
    import oracle.sql.*;
    import java.io.*;
    import java.util.zip.*;
    import oracle.jdbc.*;
    public static BLOB Decompre(BLOB inBlob, Connection conn) throws Exception
    BLOB outBlob = BLOB.createTemporary(conn, false, BLOB.DURATION_SESSION);
    byte[] input = inBlob.getBytes();
    byte[] output = new byte[103090];
    int decompressedDataLength = 0;
    Inflater decompressor = new Inflater(true);
    decompressor.setInput(input);
    decompressedDataLength = decompressor.inflate(output);
    decompressor.end();
    OutputStream outstream = outBlob.getBinaryOutputStream();
    outstream.write(output,0, decompressedDataLength);
    outstream.close();
    return outBlob;     
    public static BLOB Compre(BLOB inBlob, Connection conn) throws Exception
    BLOB outBlob = BLOB.createTemporary(conn, false, BLOB.DURATION_SESSION);
    byte[] input = inBlob.getBytes();
    byte[] output = new byte[10000000];
    Deflater compressor = new Deflater(-1,true);
    compressor.setInput(input);
    compressor.finish();
    int compressedDataLength = compressor.deflate(output, 0, output.length);
    OutputStream outstream = outBlob.getBinaryOutputStream();
    outstream.write(output,0, compressedDataLength);
    outstream.flush();
    outstream.close();
    return outBlob;
    public static BLOB CompDecomp(BLOB inBlob,String test) throws Exception
    Connection conn = inBlob.getJavaSqlConnection();
    Statement stmt = conn.createStatement();
    BLOB blob = null;
    ResultSet rset = stmt.executeQuery("SELECT ann_annotation FROM annotations WHERE ann_id="+test);
    while(rset.next()){
    blob = Decompre(Compre(((OracleResultSet)rset).getBLOB("ann_annotation"), conn), conn);
    return blob;
    The 3rd method CompDecomp is just there to test if the resulting Zipped-Unzipped BLOBe is the same as the original. This is not the case. My original file = > 100000 bytes, the Zipped one is 59 (when I zip it with Winzip, the file is still > 100000, so the error relies somewhere in saving the result into the BLOB), and Unzipped it is 84 bytes.
    Strangly the following code gives back the original BLOB:
    public static BLOB CompDecomp(BLOB inBlob, String test) throws Exception
    BLOB ultoutBlob = BLOB.createTemporary(conn, false, BLOB.DURATION_SESSION);
    byte[] input = inBlob.getBytes();
    byte[] output = new byte[10000000];
    Deflater compressor = new Deflater();
    compressor.setInput(input);
    compressor.finish();
    int compressedDataLength = compressor.deflate(output);
    byte[] input2 = output; // which is directly a byte, not a BLOB
    byte[] output2 = new byte[10000000];
    int decompressedDataLength = 0;
    Inflater decompressor = new Inflater();
    decompressor.setInput(input2);
    decompressedDataLength = decompressor.inflate(output2);
    decompressor.end();
    OutputStream outstream2 = ultoutBlob.getBinaryOutputStream();
    outstream2.write(output2);
    outstream2.close();
    return ultoutBlob;
    The only difference I see, is that I do not save the intermediate Zipped content into a BLOB.
    Edited by: user10692128 on 8-dec-2008 6:19
    Edited by: user10692128 on 8-dec-2008 6:20

    Thanks Marcelo, this helped a lot.
    I changed the code as follows:
    public static BLOB Decompress(BLOB inBlob, Connection conn) throws Exception
    BLOB outBlob = BLOB.createTemporary(conn, false, BLOB.DURATION_SESSION);
    OutputStream outstream = outBlob.getBinaryOutputStream();
    InputStream instream = inBlob.getBinaryStream();
    byte[] input = new byte[BLOB.MAX_CHUNK_SIZE];
    byte[] output = new byte[BLOB.MAX_CHUNK_SIZE];
    Inflater decompressor = new Inflater(true);
    while (true) { // read and deflate the data     
    // Fill the input array.
    int numRead = instream.read(input);
    if (numRead == -1) { // end of stream
    // Inflate any data that remains in the input buffer.
    while (!decompressor.finished()) {
    int decompressedDataLength = decompressor.inflate(output, 0, output.length);
    if (decompressedDataLength > 0) {
    outstream.write(output,0, decompressedDataLength);
    } // end if
    } // end while
    break; // Exit while loop.
    } // end if
    else {  // Inflate the input.
    decompressor.setInput(input, 0, numRead);
    while (!decompressor.needsInput()) {
    int decompressedDataLength = decompressor.inflate(output, 0, output.length);
    if (decompressedDataLength > 0) {
    outstream.write(output, 0, decompressedDataLength);
    } // end if
    } // end while
    } // end else
    } // end while
    instream.close();
    outstream.flush();
    outstream.close();
    return outBlob;     
    public static BLOB Compress(BLOB inBlob, Connection conn) throws Exception
    BLOB outBlob = BLOB.createTemporary(conn, false, BLOB.DURATION_SESSION);
    OutputStream outstream = outBlob.getBinaryOutputStream();
    InputStream instream = inBlob.getBinaryStream();
    byte[] input = new byte[BLOB.MAX_CHUNK_SIZE];
    byte[] output = new byte[BLOB.MAX_CHUNK_SIZE];
    Deflater compressor = new Deflater();
    while (true) { // read and deflate the data     
    // Fill the input array.
    int numRead = instream.read(input);
    if (numRead == -1) { // end of stream
    // Deflate any data that remains in the input buffer.
    compressor.finish();
    while (!compressor.finished()) {
    int compressedDataLength = compressor.deflate(output, 0, output.length);
    if (compressedDataLength > 0) {
    outstream.write(output,0, compressedDataLength);
    } // end if
    } // end while
    break; // Exit while loop.
    } // end if
    else {  // Deflate the input.
    compressor.setInput(input, 0, numRead);
    while (!compressor.needsInput()) {
    int compressedDataLength = compressor.deflate(output, 0, output.length);
    if (compressedDataLength > 0) {
    outstream.write(output, 0, compressedDataLength);
    } // end if
    } // end while
    } // end else
    } // end while
    instream.close();
    outstream.flush();
    outstream.close();
    compressor.reset();
    return outBlob;
    It still does not work (I seem to lose some bytes somewhere in the zipping process), but I'm getting closer. ;-)

  • Creating an XLS file and Zip it

    Hi All,
    we have a requirement where in we have to create an XLS file from internal table. This xls file then has to be zipped and mailed.
    If anyone knows how to create an xls file and zip it in WebDynpro, without using OPEN, CLOSE DATA SET etc, Please let us know. It will be of great help.
    Thanks,
    Anand

    >2) Convert the STRING format to XSTRING format by using the FM SCMS_STRING_TO_XSTRING.
    Actually you should use CL_BCS_CONVERT=>STRING_TO_XSTRING now.
    >3) Use the method COMPRESS_BINARY of class CL_ABAP_GZIP to compress the XSTRING file.
    You probably want to use CL_ABAP_ZIP instead of CL_ABAP_GZIP.  CL_ABAP_GZIP only does compression, which is fine for storing a single packet of data in the database.  However CL_ABAP_ZIP is better suited for mult-part zip (multiple inner files).
    >4) Use the method SEND_WEB_MAIL of class CL_HRRCF_SERVICES_MAIL to mail across the zipped contents.
    This seems to be an HR specific class. Better to use the cross application, NetWeaver provided functionality for sending mail - CL_BCS.

  • ApEx 3.1 BLOBs, /pls/apex/apex_util.get_blob_file not found on server

    Hi all
    I'm trying some of the enhanced BLOB functionality in one of our apps as it could really make life easier for our users.
    We have a table with 4 BLOBs that the user can use to upload various documents.
    The upload (insert / update) seems to be working OK and as far as I can tell is making it through to the database table (I've checked using dbms_lob.getlength).
    However the 'Download' link provided on the form I can't get to work for love nor money. I always get this error in the browser (all browsers) :
    The requested URL /pls/apex/apex_util.get_blob_file was not found on this server.Checking the Apache log file (we're using mod_plsql) I see that :
    [Mon Apr 07 15:46:20 2008] [error] [client XX.XX.XX.XX] [ecid: 1207579580:192.168.20.2:2060:280:1501,0] mod_plsql: /pls/apex/apex_util.get_blob_file HTTP-404 ORA-00900: invalid SQL statement\nORA-06512: at "SYS.WWV_DBMS_SQL", line 196\nORA-06512: at "FLOWS_030100.WWV_FLOW_DML", line 1537\nORA-06512: at "FLOWS_030100.HTMLDB_UTIL", line 1532\nORA-06512: at line 22\nHas anyone else seen this? I have used this function successfully elsewhere but can't work out why it's not working on this page. I have defined (and assigned) mimetype, filename & updated date columns...
    The built link looks like this :
    http://<server>/pls/apex/apex_util.get_blob_file?a=105&s=935234205856194&p=32&d=6525565218047259&i=1070820865186800&p_pk1=282&p_pk2=10&p_ck=607EA2AE0D32BCB66F3857A0458E2550&p_content_disposition=attachmentThe values for p_pk1 and p_pk2 seem correct and the a (app id) is correct also.
    Thanks,
    Steve

    Steve,
    Thanks for reporting this issue. We have a known bug in APEX 3.1 which does not let you work declaratively with BLOBs when you have multiple blobs per table. We hope to have this fixed in a patch. We also need to post it on our known issues page for interactive reports.
    Mike

Maybe you are looking for

  • In Columns mode, Preview QTs no longer have scroll bars...Why?

    I used to really like looking for files in the Finder mode, in the Column view; then finding the QT, and previewing it in the Preview column, complete with scroll bar. That was the Old Days. Is there anyway in Leopard to get the scroll bar back? (BTW

  • Reading .txt file from remote using abap?

    Hi, I must read a .txt file from remote server automatically. I have path and name of .txt file. Remote system asks username and password. In abap is it possible to give username and password for reading .txt from remote server? Remote server and sap

  • Date Changes by itself in ComboBox

    Hi Gurus, I am opening this thread in continuation to my previous thread:- Date range in Xcelsius I could resolve this issue by referencing the cells in the next column in descending order for eg. I had data in ascending order  in M3 to M38 so  what

  • Imac G3 How to get the crt off? or screen span one or the other

    I have an imac g3 3500 mh and a slot loading drive. but the crt is geting very old the computer is like 10 years. but how do i screen spam on it.. i know there is a vga port on the back of it and i have a vga screen hooked up to it at the moment but

  • Lightroom 5.5 files will not open in Photoshop 2014

    Hi. Just updated Lightroom to 5.5, and Photoshop to CC 2014, using the CC updater. Now, when in Lightroom, Command E, or the menu selection, will not open my files in Photoshop. Any ideas?