Options to Compress and Go Giant Knowledge from iOS Swift to PHP on Apache


I’ve an app that usually passes small volumes of transactional knowledge, however on the perimeter circumstances I’ve must go upwards of 200MB of text-based transactional knowledge. I can ZLIB that a lot textual content right down to 4.3MB and I can ZIP it down to five.1MB. There’s a whole lot of repetition within the knowledge.

The server that PHP is operating on permits uploads as much as 128MB, POSTs as much as 24MB, however solely permits every course of as much as 32MB and the server itself solely has 4GB of RAM in the mean time (making an attempt to have this upgraded).

I’ve discovered the next strategies to get the info to the server:

  1. Compress the textual content knowledge into NSData on iOS 13+ with NSData.compress(utilizing: .zlib), then both add the info as a file or POST it to HTTP session, however this doesn’t appear very moveable and I’ve not discovered a technique to decompress the identical knowledge appropriately in PHP with out hitting the reminiscence limits when it’s increasing the 200MB of textual content knowledge. I tried a PHP Generator, however I’m not very accustomed to that. Additionally, I am technically speculated to help right down to iOS 12, so this methodology does not fulfill my use case.
guard var compressed = data.knowledge( utilizing: .utf8 ) else { return }
if #obtainable(iOS 13.0, *) {
    compressed = attempt ( Knowledge( data.utf8 ) as NSData ).compressed( utilizing: .zlib ) as Knowledge
}
  1. Write the textual content knowledge to an area iOS file, ZIP the file, add the file to PHP, after which have PHP UNZIP the file and skim the file line-by-line. I’ve not gone as far as to implement this, but, but it surely appears fairly straight-forward aside from the line-by-line studying – what constitutes a line? Ending with ‘rn’?

Are there different choices which are extra straight-forward that I am lacking to effectively compress giant volumes of textual content, transfer it to PHP throughout the online, after which effectively use PHP to learn small chunks of the info so it does not run out of reminiscence? Thanks prematurely.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles