login about faq

I was wondering if it would be possible (in future versions?) to ZIP a BLOBfile without having to save the BLOBfile to disk, zipping the file, and saving the zipped file back to a BLOBfile. (and also the other way around, unzipping a BLOBfile)

this so save valuable time and resources ...

asked Jun 22 '12 at 06:29

SSWGlenn's gravatar image


edited Jun 22 '12 at 06:31

Something like this should work:

  1. Create a new ChilkatZip2 object
  2. Read the data from your database into a byte array.
  3. Use the ChilkatZip2.AppendData method to append the array to the new archive
  4. Use the ChilkatZip2.WriteToMemory method to retrieve the archive in a new Byte array.
  5. Call ChilkatZip2.CloseZip to clean up.
  6. Store the returned byte array of the zip file in your database.

answered Jun 26 '12 at 11:50

jpbro's gravatar image

jpbro ♦

I don't understand what a "BLOBfile" is, but I'm assuming it has to do with a binary field in a SQL Server database? In any case, the Chilkat Zip ActiveX (I assume if it's SQL Server, then you're using the ActiveX?), the Chilkat Zip API provides OpenFromMemory and WriteToMemory methods to read and write .zip archives from memory. Given this, the only task is to determine how to pass the binary data from a database field to an ActiveX method, and the reverse: how to save the returned binary data from an ActiveX to a database field.

I don't actually know the answer to that question. I may involve using a temp table as shown here for getting a long string property: http://www.example-code.com/sql/default.asp

However, in any programming language, NEVER treat binary data that does not represent actual characters as a string (i.e. never treat the binary output of encryption, or image data, or the binary data of a compressed file format such as a .zip as a string). The reason is that you never want anything to be trying to interpret those bytes as characters encoded according to some charset (such as utf-8, iso-8859-1, etc.) I say this because whatever the solution, it would involve a database field that is NOT a string, but must be something that represents binary data.


answered Jun 22 '12 at 09:37

chilkat's gravatar image

chilkat ♦♦

thanks for your answer.

a BLOB is a file (txt, xml, pdf, ...) stored in a database.

Now I have to convert the BLOB to a physical file on disk, zip it, and convert it back to a BLOB and store it in the database again. And this takes time ...


answered Jun 22 '12 at 10:13

SSWGlenn's gravatar image


edited Jun 22 '12 at 10:39

Works just great !! Just had a little trouble with the return of the WriteToMemory-method, but at the moment it works ...

Thanks a lot !!


answered Jun 27 '12 at 07:27

SSWGlenn's gravatar image


Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Jun 22 '12 at 06:29

Seen: 1,688 times

Last updated: Jun 27 '12 at 07:27

powered by OSQA