2015-09-14 31 views
0

我需要在我餘下的Api中返回zip文件,但我收到的MIME媒體類型application/zip找不到。我沒有找到MIME媒體類型應用程序/郵編麼?

@Produces({ "application/zip" }) 
    public Response convertFile(){ 
    . 
    . 
    . 
    return Response.ok(result, "application/zip").build(); 
} 
+0

您需要創建自己的['MessageBodyWriter'(https://jersey.java.net/documentation/latest/message-body-workers.html#d0e6791)爲'應用/ zip'和Java類型或只使用'application/octect-stream' –

回答

0

試試這個:

@Produces("application/zip") 

return Response 
      .ok(FileUtils.readFileToByteArray(resultFile)) 
      .type("application/zip") 
      .header("Content-Disposition", "attachment; filename=\"yourfile.zip\"") 
      .build(); 
+0

謝謝。我嘗試過,但我有同樣的錯誤。 – Fariba

+0

嘗試通過Chrome中的郵遞員發送請求。 –

相關問題