如何在Erlang中解压缩解压缩multipar/form-data?

9q78igpj  于 2022-12-08  发布在  Erlang
关注(0)|答案(1)|浏览(275)

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?

pxiryf3j

pxiryf3j1#

看起来您尝试的unzipPayload/*.zip数据/文件已损坏或未正确打包,请参阅zip.erl中的逻辑。示例如下:

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}

确保在Payload中提供了正确的数据。

相关问题