Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

280
Views
Decompress LZMA-JS compressed file in Java

I'm compressing my image (in base64 string format) on client side using LZMA-JS, and then sending the compressed byte array to server. There I want to decompress the byte array and save it in DB.

Client Code:

LZMA.compress(base64Img, 9, function on_compress_complete(result) {
imageCallback(result);
            }, function on_compress_progress_update(percent) {
                console.log("Compressing: " + (percent * 100) + "%");
            });

I tried using LZMACompressorInputStream and LZMA2InputStream at server to decompress the same, but both give "org.Pukalani.xz.CorruptedInputException: Compressed data is corrupt" exception.

Server Side Code:

private byte[] decompressByteArray(final byte[] bytes) throws IOException {
        try (final ByteArrayOutputStream os = new ByteArrayOutputStream();) {
            final ByteArrayInputStream in = new ByteArrayInputStream(bytes);
            final LZMACompressorInputStream gis = new LZMACompressorInputStream(in);
            final byte[] buffer = new byte[1024];
            int len;
            while ((len = gis.read(buffer)) != -1) {
                os.write(buffer, 0, len);
            }
            gis.close();
            return os.toByteArray();
        } catch (final IOException e) {
            log.error("error", e);
            return new ByteArrayOutputStream().toByteArray();
        }
    }

Is there any other way to decompress the byte array? I have a around 30 images in base64 format which I want to send in single call, is there any other way to send these across.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!