Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

282
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda