2015-04-23 70 views
0

我正在开发safari扩展,并希望在我的网站上发布扩展。我使用下面的代码,使用户能够下载.safarixtz文件,然后安装: -通过网络服务器提供的Safari扩展

<%String filename = "<safariextz file path>" ;   
response.setContentType("application/octet-stream safariextz"); 

String disHeader = "Attachment;filename=test-safari.safariextz"; 
response.setHeader("Content-Disposition", disHeader); 

// transfer the file byte-by-byte to the response object 
File fileToDownload = new File(filename); 
response.setContentLength((int) fileToDownload.length()); 
FileInputStream fileInputStream = new FileInputStream(fileToDownload); 
int i = 0; 
while ((i = fileInputStream.read()) != -1) { 
    out.write(i); 
} 
fileInputStream.close();%> 

但生成的文件不能在Safari浏览器和投掷错误安装: -

Safari浏览器无法安装此扩展程序 安装此扩展程序时发生错误

我也希望安装开始的时刻用户点击安装链接就像在苹果画廊。

谢谢

+1

你使用什么语言/平台为你的Web服务器? –

+0

这可能是因为您的下载代码没有正确下载所有字节。你有没有试过比较校验和? – dimitrirostavo

+0

语言看起来像[JSP](http://www.tutorialspoint.com/jsp/jsp_syntax.htm)@StevenSchobert – MauroPerez

回答

0

这是因为您的扩展有错误。你能否分享你的分机,以便我可以帮你检查。

另外,不要使用这些代码来为扩展文件提供服务。你不需要这个。

所有你需要做的是 - 上传你的扩展到服务器的公共文件,你会得到它 的URL - 修改服务器的配置文件(Apache或其他一些HTTP服务器可以与添加一个很容易配置在配置文件中行)来处理.safariextz文件

你完成了。

首先确保你的扩展没有错误。

相关问题