[英]Zip file size getting compromise while uploading zip file as octet-stream content type using rest service
我的休息界面是:
@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);
}
}
如果我正在使用APPLICATION_OCTET_STREAM
content-Type,則會得到zipEntry null。
有沒有一種方法可以使用上述其余端點配置來上傳zipfile?
應用程序八位字節流提供文件參數
@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.