Android Question How Can I Decompress brotli content encoding

abbas abedi

Member
hi
How Can I Decompress brotli content encoding

this is my Answer headers

B4X:
content-type: application/json
vary: Accept-Encoding
vary: Accept-Encoding
vary: Origin
grpcgateway-content-type: application/grpc
access-control-allow-origin: https://divar.ir
access-control-allow-credentials: true
access-control-expose-header: api.xxxxx.com
strict-transport-security: max-age=31536000
x-zrk-us: 200
server: Sotoon
x-zrk-cs: BYPASS
x-zrk-sn: afrashz1
content-encoding: br

Untitled.jpg
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Code and logs should be posted as text.

1. Download: https://repo1.maven.org/maven2/org/brotli/dec/0.1.2/dec-0.1.2.jar
2.
B4X:
#AdditionalJar: dec-0.1.2.jar

3.
B4X:
Sub Button1_Click
    Dim b() As Byte = DecompressInputStream(File.OpenInput(File.DirAssets, "10x10y.compressed"))
    Log(BytesToString(b, 0, b.Length, "utf8"))
End Sub

Sub DecompressInputStream(in As InputStream) As Byte()
    Dim jo As JavaObject
    jo.InitializeNewInstance("org.brotli.dec.BrotliInputStream", Array(in))
    Return Bit.InputStreamToBytes(jo.As(InputStream))
End Sub

It will also work in B4J.
 
Upvote 0
Top