2014-10-27 74 views
1

有哪些不同的方法來從Java服務器發送PDF到Android設備 和哪一個最好的辦法從Java服務器發送PDF到Android設備

  • 我們可以發送大尺寸的PDF(> 25 MB)在JSON到Android設備
  • 是否有任何其他的方式發送PDF格式的設備(即其他然後在JSON)

(大多采用Spring集成)

回答

2

你可以試試這個,使用Jax RS的一種方式, 它不使用JSON。它讓文件下載到設備上。

@GET 
@Path("/{fileName}/excel") 
//Your Proper URL,using the fileName let you the download the specific pdf 
@Produces("application/pdf") 
public Response getFileInPDFFormat(@PathParam("fileName") String fileName) 
{ 
    String filePath="";// Your File Path 

    //Put some validations here such as invalid file name or missing file name 
    if(fileName == null || fileName.isEmpty()) 
    { 
     ResponseBuilder response = Response.status(Status.BAD_REQUEST); 
     return response.build(); 
    } 

    File file = new File(filePath); 

    ResponseBuilder response = Response.ok((Object) file); 
    response.header("Content-Disposition", "attachment; filename='"+fileName+"'"); 


    return response.build(); 
} 
0

發送(從服務器端發起下載到Android)它需要與谷歌雲消息GCM安裝Android應用程序和服務器端的推送通知消息到Android =從部分路段和未來的Android應用開始下載將開始下載(可以通過Web服務訪問pdf,可以使用/不使用安全性,如JaxRS,Apache www root dir,但不安全或使用某些ftp)

相關問題