composer require "hzz/repo-storage @dev"
// gitee
// $entity = \Hzz\StorageEntity::create('gitee',"对应gitee平台的token");
$entity = \Hzz\StorageEntity::create('github',"对应github平台的token");
// 请求参数说明
$_data = [
'owner' => "", // 用户名
'repo' => "", // 仓库名称
'path' => "", // 文件存储的路径
'file' => "", // 上传时使用文件绝对路径,删除时使用仓库中对应的文件名
'sha' => "", // 删除文件的 sha 标识
];
// 上传
$date["owner"] = "hezhizheng";
$date["repo"] = "static-image-hosting";
$date["path"] = "files";
$date["file"] = "/xxxpath/1.png";
$res = $entity->put($date); // 文件访问地址 github为 $res['content']['cdn_url'] gitee 为 $res['content']['download_url']
// 删除
$date["owner"] = "hezhizheng";
$date["repo"] = "static-image-hosting";
$date["path"] = "files";
$date["file"] = "20210317170512_6051c64896104.png";
$date["sha"] = "213231fd035a1ea05e5ccaba94cfa4d1acd6e81d";
$entity->delete($date);
// 获取文件
$date["owner"] = "hezhizheng";
$date["repo"] = "static-image-hosting";
$date["path"] = "files";
$entity->get($date);
-- END
写的不错,赞助一下主机费
暂无评论~~