Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8451157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:09:42+00:00 2026-06-10T11:09:42+00:00

I have a zip file which I store in the database as a blob

  • 0

I have a zip file which I store in the database as a blob field. When I want to download it from it the zip file is corrupted. I can open it only from 7zip. The file is ok when I try to open it before upload it in the DB and when is in the DB. When I retrieve the file from the database as a blob I get this error when try to unzip it on unix

    Archive:  test.zip
      End-of-central-directory signature not found.  Either this file is not
      a zipfile, or it constitutes one disk of a multi-part archive.  In the
      latter case the central directory and zipfile comment will be found on
      the last disk(s) of this archive.
    unzip:  cannot find zipfile directory in one of test.zip or
            test.zip.zip, and cannot find test.zip.ZIP, period.

Here is the code when I retrieve the zip from the database :

        public oracle.sql.BLOB GetBlob(Connection myConn, 
                                       CallableStatement cstmt) throws Exception {
            String strSql = null;

            BLOB tempBlob = null;
            try {

                strSql = .... // Here is the sql procedure which I called to retrieve the blobl field.
                cstmt = myConn.prepareCall(strSql);
                cstmt.registerOutParameter(1, OracleTypes.BLOB);
                cstmt.setLong(2, request_id);
                cstmt.execute();
                tempBlob = (oracle.sql.BLOB)cstmt.getObject(1);
                int bufsize = tempBlob.getBufferSize();

            } catch (Exception e) {
                e.printStackTrace();
                throw e;
            }
            return tempBlob;

Here is the reading :

                oracle.sql.BLOB tempBlob = null;
            Connection myConn = null;
            CallableStatement cstmt = null;

            try {
                myConn = DBHelper.getConnection();
                if (null == myConn)
                    throw new SQLException();
                tempBlob = GetBlob(myConn, cstmt);

                int bufsize = tempBlob.getBufferSize();
                InputStream in = tempBlob.getBinaryStream();
                int length = 0;

                byte buf[] = new byte[bufsize];
                while ((in != null) && ((length = in.read(buf)) != -1)) {
                    out.write(buf, 0, length);

                }
                in.close();
                //          out.flush();
                //          out.close();
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                if (null != myConn) {
                    try {
                        myConn.close();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                if (cstmt != null) {
                    try {
                        cstmt.close();
                    } catch (SQLException e) {
                    }
                }

            }

Could somebody help me.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T11:09:44+00:00Added an answer on June 10, 2026 at 11:09 am

    Compare the files before and after. The difference should give you some hint what is going wrong.

    Possible culprits are:

    • Missing bytes at the end
    • converted bytes
    • messed up order of bytes

    I’d expect looking at the first 10, the last 10 and the total number of bytes should be sufficient to give you a good idea what is going on.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a zip file which can contain any number of zipfiles inside it
I have a FileUploader class that can optionally be given a zip file which
I have .zip file which contain csv data. I am reading .zip file using
In one of my git projects, I have a zip file which bundles a
I have created password protected zip file which has xls file with the help
I have a perl script URL which gives me a ZIP file, it processes
I have inherited some code (from zip file) from a developer and git initialzed,
I have a ruby bash script to download a zip file and output a
I have a zip file which has one base folder inside it with other
I have a zip file which contains the following directory structure: dir1\dir2\dir3a dir1\dir2\dir3b I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.