gpt4 book ai didi

google-chrome - 如何托管 Chrome 扩展程序?

转载 作者:行者123 更新时间:2023-12-04 17:54:31 29 4
gpt4 key购买 nike

我需要使用 PHP 在我的共享主机上托管我的 chrome 扩展。

我知道我的服务器必须使用适当的 HTTP header :code.google.com/chrome/extensions/hosting.html

但是,如何设置我的服务器以沉迷于 .crx 文件发送这些 header ?

最佳答案

如果您在共享主机上并且无法更改服务器配置,请使用 PHP:

<?php
$file = 'extension.crx';

if (file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/x-chrome-extension');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
exit;
}
?>

source

这将强制下载带有自定义标题的文件(由 $file 变量指定)。

关于google-chrome - 如何托管 Chrome 扩展程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10737123/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com