Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

285
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda