How to convert the following string to a zip file that contains a csv in Meteorjs

Hi there,

I am sent the following string via JSON. The string is a zip file that contains a csv file.

UEsDBBQACQBjACWmHlMAAAAAHAAAAAAAAAAVAAsAMTg4MjI3N18yNTU0Mzk2ODIuY3N2AZkHAAIAQUUDAACG1iN28+zBI4k75jzFV1xMdh9Tzc3kyOd5VbHkUEsHCAAAAAAcAAAAAAAAAFBLAQIUABQACQBjACWmHlMAAAAAHAAAAAAAAAAVAAsAAAAAAAAAAAAAAAAAAAAxODgyMjc3XzI1NTQzOTY4Mi5jc3YBmQcAAgBBRQMAAFBLBQYAAAAAAQABAE4AABqAAAAAAA=

The name of the file is 1882277_255439682.zip"

How do I convert the string above back to the zip file or csv file in Meteorjs? Please help.

The JSON sent to me is:

error : null,
responseCode : "SUCCESS",
orderReferenceId : 255439682,
fileName : "1882277_255439682.zip",
filePassword : "some password to be used once the csv is received by the client",
file : UEsDBBQACQBjACWmHlMAAAAAHAAAAAAAAAAVAAsAMTg4MjI3N18yNTU0Mzk2ODIuY3N2AZkHAAIAQUUDAACG1iN28+zBI4k75jzFV1xMdh9Tzc3kyOd5VbHkUEsHCAAAAAAcAAAAAAAAAFBLAQIUABQACQBjACWmHlMAAAAAHAAAAAAAAAAVAAsAAAAAAAAAAAAAAAAAAAAxODgyMjc3XzI1NTQzOTY4Mi5jc3YBmQcAAgBBRQMAAFBLBQYAAAAAAQABAE4AAABqAAAAAAA=,
created : 1630349360877

How did you create the string?

It was created using a java library “net.lingala.zip4j”. It looks it is a library used to minify the csv. It is apparently similar to “java.util.zip”. Is there a way to view the csv zipped/compressed in this manner in Meteorjs? Thanks for helping.

It has an important difference compared to the built-in Java zip library - this one accepts streams :slight_smile:. However, this is for now besides the point. It looks like you are dealing with a base64 encoded (possibly also password-protected) zip file. Meteor JS can do anything that Node.js (on the server) and the browser JavaScript environment (on the client) can do. Solving the problem at hand does not require anything Meteor specific.

So you will need to have a method for translating your string on the server side into a zip file (perhaps as explained here), then unzip the resulting file (perhaps with something like this NPM package).

Needs a little bit of elbow grease, but certainly doable. Good luck!

Uhm… then this isn’t a string, this is a byte sequence, a little different. Do you need to find some lib in Node to “unzip” this byte sequence to a clear data.

As @illustreets said, you can use any Node lib to handle with zip files. My concern is how you are reading the file and creating the byte sequence.