1. Richard Carrier
  2. PowerBuilder
  3. Tuesday, 12 November 2019 22:08 PM UTC

So we have a document management system and I want all documents to be zipped before uploading. We are storing the document in a standard table Blob column. We first used Chilkat but that requires a temp folder so we switched to the appeon built in stream.

 

Question: - we also want all files downloaded from our system to be written as a zip files but I don't see the ability to create a zip file from Appeon. 

Also, downloading the file and renaming the extension to .zip does not work because it's not a real zip file, just a compressed file.

 

Any help or suggestions always appreciated.

 

Thanks

Richard

 

Roland Smith Accepted Answer Pending Moderation
  1. Wednesday, 13 November 2019 15:38 PM UTC
  2. PowerBuilder
  3. # 1

You could use my ZLIB implementation which can be used to create and extract .zip files and compress/uncompress blobs for storage in the database. For the database, you'll need to store the original size in a number column because it is an input to the uncompress function. I would also add a compressed size column. That way you could easily write a query to tell you the average compression rate.

http://www.topwizprogramming.com/freecode_zlibwapi.html

 

Comment
There are no comments made yet.
Michael Kramer Accepted Answer Pending Moderation
  1. Tuesday, 12 November 2019 22:39 PM UTC
  2. PowerBuilder
  3. # 2

As I read you, you want to read document files from disk - to then store that file's content to a BLOB field in the database in a compressed format. Also, you want to extract the stored objects and save them to (compressed) files. Correct?

Now, if I'm correct - here is what I would consider:

  • Use PowerBuilder's new Compressor object class which supports compression into ZIP, 7ZIP, GZIP, or TAR format.
  • Use the variant of its Compress function working on BLOB data to be "stream"-ish.
  • You will need to read the contents of the file from disk into a BLOB - before calling Compress.
  • When you have a document in compressed format, you can do any of these:
    • Save it to database using UPDATEBLOB.
    • Save it to file using FileOpen; FileWriteEx; FileClose.
      I would use a file extension that matches the compression type, like ZIP or TAR.
  • Alternatively you can read the compressed document into memory by any of these:
    • Read from database using SELECTBLOB.
    • Read from file using FileOpen; FileReadEx, FileClose.
  • Un-compress  is called Extract in PowerBuilder.
    • Class = ExtractorObject
    • Function = Extract

PowerBuilder can extract a few more formats than it can compress.

HTH /Michael

 

Comment
  1. Michael Kramer
  2. Tuesday, 12 November 2019 23:31 PM UTC
Ah, got ya! I tested compress and extract when they were brand new. As I remember my WinZip could read the ZIP file created by the compressor. But let me find my that demo and redo my test. I never throw out demo code.

In the mean time, other may jump into the discussion because they already tested.

Eureka! I suddenly remember my learnings =>

ZIP from blob to blob => This only compresses because there is no file system info related to the data. It is data-only.

ZIP from file/folder to file => Here I get the file and folder info included and hence a real ZIP file. I don't see easy way of avoiding files to do include file info in a ZIP file.

I vaguely remember saving data into a TEMP folder with sub-folder structure; then do ZIP in the TEMP structure; read the ZIP file, then delete all TEMP files as part of cleanup.
  1. Helpful
  1. Roland Smith
  2. Wednesday, 13 November 2019 15:47 PM UTC
One of my apps uses my ZLIB object to compress files into blobs before storing them in the database and uncompress before saving blobs back to files. The PowerBuilder compressor object uses ZLIB.dll to do what it does. My example uses zlibwapi.dll which is based on the same code except the functions are declared so that they can be called from PowerBuilder, VB6, or other similar languages.
  1. Helpful
  1. Roland Smith
  2. Wednesday, 13 November 2019 15:48 PM UTC
I'm unaware of a way to produce a .zip file completely in memory. You would have to create it in the users temp folder, read it into a blob, delete the file, and then save the blob to the database.
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.