ファイアウォールの背後に保存されているビデオ (mp4) がいくつかあります。PDF、DOC などの他のドキュメントを RESTful Web サービス経由で外部サイトに提供するために使用される Java プロキシがあります。この同じ Web サービスは、PC ブラウザのビデオでも機能しますが、iPad では、再生ボタンがブロックされた黒い画面が表示されます。ビデオの直接の場所を参照すると、正常に再生されます。これにより、ビデオは問題ないと思いますが、それをバックアップする Web サービス コードに何かが欠けています。そこに何かアイデアはありますか?iPadでこれを征服した人はいますか?
@GET
@Path("/open/{objectId}/{ticket}/{objectName}/")
public Response openDocument(@PathParam("objectId") String objectId, @PathParam("ticket") String ticket, @PathParam("objectName") String objectName) throws Exception {
return download(objectId, ticket, objectName, false);
}
private Response download(String objectId, String ticket, String objectName, boolean attachment) throws Exception {
String url = "";
if (objectName.endsWith(".mp4")) {
url = "http://videosite.com/videos/" + objectName;
}
else {
url = "http://documentsite.com/" + objectName;
}
DefaultHttpClient client = new DefaultHttpClient();
HttpGet get = new HttpGet(url);
try {
HttpResponse response = client.execute(get);
HttpEntity entity = response.getEntity();
StatusLine status = response.getStatusLine();
if (status.getStatusCode() == 200 || status.getStatusCode() == 206) {
ResponseBuilder rb = Response.ok(entity.getContent());
rb.header("Connection", "Keep-Alive");
rb.header("Content-Length", entity.getContentLength());
rb.header("Content-Type", entity.getContentType().getValue());
rb.header("Keep-Alive", "timeout=5, max=99");
if (attachment) rb.header("Content-Disposition", "attachment; filename=\"" + objectName.replaceAll("\\+", " ") + "\"");
else rb.header("Content-Disposition", "filename=\"" + objectName.replaceAll("\\+", " ") + "\"");
return rb.build();
}
else return Response.noContent().build();
}
catch (Exception e) {
e.printStackTrace();
return Response.noContent().build();
}
}