问题
The following is my method signature.
@POST
@Path("/upload/{user_id}/{user_type}")
@Produces("application/json")
public Response fileUploader(InputStream a_fileInputStream,
@PathParam("user_id") String user_id,
@PathParam("user_type") String logType,
@Context ContainerRequestContext crc) {
//WRITE INPUTSTREAM TO FILE
}
I am able to write content to my file successfully, but there is some meta data which is written to my file at start of my file the following meta data is written:
------WebKitFormBoundaryvsdfdsffsdrsr
Content-Disposition: form-data; name="fileUpload"; filename="2mb.txt"
Content-Type: text/plain
at end of my file
------WebKitFormBoundaryvsdfdsffsdrsr
I dont want these meta data to be present in my file.
I am using Advance REST Client chrome plugin and using the following parameters:
METHOD : POST
url : http://localhost:8080/api/upload/1/normal
Content-Type: application/octet-stream
added one file to it : 2mb.txt
I want to use this api with curl so the following is my curl command:
curl -XPOST http://localhost:8080/api/upload/1/normal --data-binary @2mb.txt
I just want to remove those lines from my file which I am creating.
Thank you.
回答1:
Place the @FormDataParam("fileUpload")
annotation in front of the InputStream
parameter.
来源:https://stackoverflow.com/questions/38849911/removing-meta-data-from-the-file