[英]Zip file size getting compromise while uploading zip file as octet-stream content type using rest service
My rest interface is: 我的休息界面是:
@POST
@Path ("/xy/v1/xyz")
@Consumes({ MediaType.APPLICATION_OCTET_STREAM})
@Produces({ MediaType.APPLICATION_JSON })
Response import(InputStream fileInputStream, @Context HttpHeaders headers,
@Context HttpServletRequest httpServletRequest,
@Context UriInfo info) {
try (ZipInputStream zipInputStream = new
ZipInputStream(fileInputStream))
{
ZipEntry zipEntry = zipInputStream.getNextEntry();
while (zipEntry != null)
{
if(!zipEntry.isDirectory())
{
data= new String(IOUtils.toByteArray(zipInputStream));
fileName = zipEntry.getName().substring(zipEntry.getName().lastIndexOf("/")+1);
list.add(
//...
);
}
zipInputStream.closeEntry();
zipEntry = zipInputStream.getNextEntry();
}
}
catch (IOException e)
{
LOG.error("Exceptions occured while reading",e);
}
}
I'm getting zipEntry null if I'm using APPLICATION_OCTET_STREAM
content-Type. 如果我正在使用
APPLICATION_OCTET_STREAM
content-Type,则会得到zipEntry null。
Is there a way to upload zipfile using above rest endpoint configuration? 有没有一种方法可以使用上述其余端点配置来上传zipfile?
Application octet stream supplies File arguments 应用程序八位字节流提供文件参数
@POST
@Path("upload")
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
@Produces(MediaType.TEXT_PLAIN)
public String upload(File f) {
// ... The file contains the data uploaded
return "ok";
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.