Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a Zip File in Memory ios swift?

We have stored image as an encrypted format and stored in local path. And once we captured the all documents the user click on submit button on that scenario we have decrypted all the images using RNCryptor(https://github.com/RNCryptor/RNCryptor) and save as Zip and https://github.com/marmelroy/Zip

But we have to store a decrypt format in memory instead of disk.

How would I zip a file so I could send it without writing to the hard drive and do it purely in memory?

like image 310
HariKarthick Avatar asked Dec 01 '25 13:12

HariKarthick


1 Answers

Update

Another alternative is the ZIPFoundation library on Github (MIT/Thomas Zoechling). It appears to be Swift compatible and is apparently "effortless." BTW - I learned about this library while reading an interesting blog article where the author (Max Desiatov) walks through how he unzips in memory using the library (see the section - Unzipping an archive in memory and parsing the contents).

Original

Have you taken a close look at the Single-Step Compression article? There is a section that talks about writing the compressed data to file (but it's already been compressed in memory at that point). Once you get the data generated then I guess you could do with it as you will...

Article Steps

  1. Create the Source Data
  2. Create the Destination Buffer
  3. Select a Compression Algorithm
  4. Compress the Data
  5. Write the Encoded Data to a File
  6. Read the Encoded Data from a File
  7. Decompress the Data
like image 164
Tommie C. Avatar answered Dec 04 '25 04:12

Tommie C.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!