I have a Erlang application and I need to read a zip file pass in a POST request. At the moment I'm use this solution but return an error.
FileUnziped = zip:unzip(Payload),
I pass in a body of a post request like this image
And the error is:
{error,bad_eocd}
Is there any solution for this problem?
Looks like the Payload
/*.zip
data/file what you try unzip
is damaged or improperly packed, see logic in zip.erl.
Here is example:
1> {ok, Data} = file:read_file("tester.txt.zip").
{ok,<<80,75,3,4,10,0,0,0,0,0,133,165,69,81,0,0,0,0,0,0,0,0,0,0,0,0,10,...>>}
2> zip:unzip(Data).
{ok,["tester.txt"]}
3> zip:unzip(<<Data/binary, "break archive">>).
{error,bad_eocd}
Make sure that in Payload
provided correct data.