Removing meta data from the file

跟風遠走 提交于 2019-12-25 04:22:13

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!