0

I have this http request to upload a image (application/octet-stream). I don't know how to receive this application/octet-stream from server side (java spring servlet). I try to do this

request.getPart("ax_file_input");

but I get null.

Here is the request looks like:

Header:

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 

Request Payload:

------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--
1

1 Answer 1

1

Apache commons fileupload can be used to parse a multipart request (which is what you'll need to upload a file).

There is an example here: http://codingitforward.blogspot.com/2010/01/java-upload-servlet.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.