1 Star 0 Fork 5

Junerver/WopiHost

forked from imoney/WopiHost 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
index.php 1.32 KB
一键复制 编辑 原始数据 按行查看 历史
imoney 提交于 2014-10-08 20:08 . php wopihost example with pux
<?php
require 'vendor/autoload.php';
use Pux\Mux;
use Pux\Executor;
class FilesController {
public function getFileInfoAction($name) {
$path = "office/$name";
if (file_exists($path)) {
$handle = fopen($path, "r");
$size = filesize($path);
$contents = fread($handle, $size);
$SHA256 = base64_encode(hash('sha256', $contents, true));
$json = array(
'BaseFileName' => $name,
'OwnerId' => 'admin',
'Size' => $size,
'SHA256' => $SHA256,
'Version' => '222888822'
);
echo json_encode($json);
} else {
echo json_encode(array());
}
}
public function getFileAction($name) {
$path = "office/$name";
if (file_exists($path)) {
$handle = fopen($path, "r");
$contents = fread($handle, filesize($path));
header("Content-type: application/octet-stream");
echo $contents;
}
}
}
$mux = new Mux;
$mux->get('/files/:name', ['FilesController','getFileInfoAction']);
$mux->get('/files/:name/contents', ['FilesController','getFileAction']);
$path = $_SERVER['PATH_INFO'];
$args = explode("&", $path);
$route = $mux->dispatch( $args[0] );
Executor::execute($route);
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/junerver/WopiHost.git
git@gitee.com:junerver/WopiHost.git
junerver
WopiHost
WopiHost
master

搜索帮助