当前位置: 首页 > news >正文

借助gitee仓库构建私有图床

  • 架构和准备
  • 具体实现细节
    • 仓库和源码地址
    • 服务端
    • yaml配置
    • 启动类
    • 同步git 云图
  • 演示

借助gitee仓库构建私有图床

架构和准备

  1. 创建gitee服务端仓库
  2. 创建gitee图床仓库
  3. 日常图片存储gitee仓库,通过git提交,保障本地电脑和云上备份双份
  4. 创建spring-boot服务端应用,实现预览图片路径为gitee图床
  5. 创建spring-boot客户端应用,实现远程服务端同步git pull命令
  6. 部署服务通过nginx域名代理
  7. 服务端部署

具体实现细节

仓库和源码地址

gitee 图片仓库[https://gitee.com/kcnf_open/wiki]

gitee 服务端仓库[https://gitee.com/kcnf_open/kcnf-wiki]

服务端
<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies>
yaml配置
#app server: port: 8086 servlet: context-path: / #spring spring: main: allow-bean-definition-overriding: true devtools: restart: enabled: false profiles: active: dev web: resources: static-locations: file:${IMAGE_BASE_PATH:/data/wiki}/, classpath:/static/
启动类
package com.jysemel.kcnf; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ApplicationContext; import org.springframework.scheduling.annotation.EnableScheduling; /** * @author jysemel */ @Slf4j @EnableScheduling @SpringBootApplication public class WikiApplication implements CommandLineRunner { @Autowired private ApplicationContext context; public static void main(String[] args) { log.info("砍材农夫 开始启动........................................"); SpringApplication.run(WikiApplication.class, args); log.info("砍材农夫 启动成功........................................"); } @Override public void run(String... args) throws Exception { // 更简单的方法:直接输出配置值 String path = context.getEnvironment().getProperty("IMAGE_BASE_PATH"); log.info(">>> IMAGE_BASE_PATH {}", path); log.info(">>> static-locations {}" , context.getEnvironment().getProperty("spring.web.resources.static-locations")); } }
同步git 云图
package com.jysemel.kcnf.controller; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import java.io.IOException; @Slf4j @RestController public class GitController { @Autowired private ApplicationContext context; @SneakyThrows @GetMapping("/admin/pull") public String pull() throws IOException { String path = context.getEnvironment().getProperty("IMAGE_BASE_PATH"); log.info(">>> IMAGE_BASE_PATH {}", path); Process process = Runtime.getRuntime().exec("git -C "+ path +" pull"); int code = process.waitFor(); return code == 0 ? "success" : "failed"; } }

演示

http://www.jsqmd.com/news/736171/

相关文章:

  • AI_08_coze_私有数据访问
  • 2026TOP级妈祖造像厂家名录:古建筑雕刻/大型石雕/妈祖造像/寺庙石雕/山门石亭/惠安石雕/石凉亭/石雕佛像/选择指南 - 优质品牌商家
  • Audiveris乐谱识别:从图像到数字乐谱的5步转换全攻略
  • 本地部署DeepSeek Coder:免费开源AI编程助手集成Cursor编辑器全攻略
  • ComfyUI-Impact-Pack V8终极指南:快速掌握AI图像增强与面部精细化技术
  • 32ms、百万行、万人并发:金山办公在表格里建了一座基础设施
  • 本地部署DeepSeek-Coder:打造私有化AI编程助手完整指南
  • AI工程化实践:基于MCP与工作流编排构建健康数据聚合服务
  • 2025届最火的六大降重复率工具实测分析
  • 抖音内容保存难题,如何优雅地构建个人数字收藏馆?
  • CarSim仿真效率翻倍秘籍:巧用Library和Category管理你的海量测试用例
  • 别再手动画封装了!用SnapEDA和Ultra Librarian快速搞定Altium Designer元件库
  • 游戏性能加速器:DLSS文件智能管理全攻略
  • PC终于翻身了:为什么OpenClaw的成功,其实跟AI无关
  • 5分钟彻底解锁QQ音乐加密格式:qmc-decoder终极指南
  • RDMA与异构计算在医学影像系统中的应用
  • STM32驱动开发避坑:三种微秒延时实现实测(SysTick/FreeRTOS/定时器)
  • 2026泰州网站优化哪家可靠?本地服务商实力盘点 - 优质品牌商家
  • 别再让网络抽风了!手把手教你排查和解决MAC地址漂移(附Wireshark抓包分析)
  • 如何免费修改植物大战僵尸:PvZ Toolkit完整使用教程
  • 从AMS1117到国产LDO:我的电源方案选型‘血泪史’与5个避坑要点
  • ROS 2里程计消息避坑指南:从TF广播到nav_msgs/Odometry的正确姿势
  • 终极指南:用OpenCore Legacy Patcher让旧款Mac完美运行最新macOS系统
  • 嵌入式多平台开发中的硬件抽象与跨平台构建实践
  • 别再让Telnet裸奔了!手把手教你用Wireshark抓包验证明文传输风险
  • OpenTentacle:为AI Agent打造透明可控的灵魂缰绳
  • 算法训练营第十九天| 1047. 删除字符串中的所有相邻重复项
  • Hive分区表数据清理实战:从‘清空2020年男生数据’案例讲起
  • 3分钟搞定NCM转换:ncmdump终极解密指南,让网易云音乐真正属于你
  • 2026工业高压清洗机厂家权威推荐榜:标杆推荐解析 - 优质品牌商家