gpt4 book ai didi

Java servlet 处理应用程序/八位字节流用于图像上传

转载 作者:行者123 更新时间:2023-12-01 09:28:33 26 4
gpt4 key购买 nike

我有一个上传图像的http请求(application/octet-stream)。我不知道如何从服务器端(java spring servlet)接收这个应用程序/八位字节流。我尝试这样做

request.getPart("ax_file_input");

但我得到了空。

请求如下所示:

标题:

Accept:*/*
Accept-Encoding:gzip, deflate
Accept-Language:en-US,en;q=0.8,zh-TW;q=0.6,zh;q=0.4,ja;q=0.2
Connection:keep-alive
Content-Length:27530
Content-Type:multipart/form-data; boundary=---- WebKitFormBoundarymuhts7ls9NLoqkUW

请求负载:

------WebKitFormBoundarymuhts7ls9NLoqkUW
Content-Disposition: form-data; name="ax-max-file-size"

10485760
------WebKitFormBoundarymuhts7ls9NLoqkUW
Content-Disposition: form-data; name="ax-thumbPostfix"

_thumb

------WebKitFormBoundarymuhts7ls9NLoqkUW
Content-Disposition: form-data; name="ax-thumbHeight"

0
------WebKitFormBoundarymuhts7ls9NLoqkUW
Content-Disposition: form-data; name="ax-thumbWidth"

0
------WebKitFormBoundarymuhts7ls9NLoqkUW
Content-Disposition: form-data; name="ax-file-size"

25896
------WebKitFormBoundarymuhts7ls9NLoqkUW
Content-Disposition: form-data; name="ax-file-name"

avatar3.png
------WebKitFormBoundarymuhts7ls9NLoqkUW
Content-Disposition: form-data; name="ax_file_input"; filename="blob"
Content-Type: application/octet-stream


------WebKitFormBoundarymuhts7ls9NLoqkUW
Content-Disposition: form-data; name="ax-start-byte"

0
------WebKitFormBoundarymuhts7ls9NLoqkUW
Content-Disposition: form-data; name="ax-file-md5"


------WebKitFormBoundarymuhts7ls9NLoqkUW--

最佳答案

Apache commons fileupload 可用于解析多部分请求(这是上传文件所需的)。

这里有一个例子: http://codingitforward.blogspot.com/2010/01/java-upload-servlet.html

关于Java servlet 处理应用程序/八位字节流用于图像上传,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39645559/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com