repo-storage 使用代码托管平台(github|gitee)做自己 '私有' 的 '对象存储'

repo-storage 使用代码托管平台(github|gitee)做自己 ‘私有’ 的 ‘对象存储’

github 地址

功能

  • 支持github(jsdelivr加速)/gitee
  • 已实现 上传 、删除、文件获取 接口

使用


// 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);
本作品采用《CC 协议》,转载必须注明作者和本文链接
hezhizheng
hezhizheng
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
讨论数量: 5

1 这个使用场景是什么?用来备份大文件资料?

3年前 评论
hezhizheng

@WadeYu 自己主要是用来当图床用,至于你说的备份大文件应该是可以的(没测过文件大小的上限),这个还得看对应平台的仓库容量。

3年前 评论
fatrbaby

牛逼,我最近正在研究私有对象存储相关的技术,现在又有学习对象了。

3年前 评论

@hezhizheng 之前有人用go语言实现的使用gitee做图床的库 github.com/hezhizheng/gitee-image-...

3年前 评论
hezhizheng

@WadeYu 就是我弄的 :joy: 同时支持github跟gitee的了 这个php版方便在项目中使用

3年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!