写了一个基于 API 的简单图床 AUXPI

动机

一直想自己调一下各种图床的 api ,本来想用 Laravel 也模仿着写一下,但是不想把项目写的那么大,恰好,最近在学 Go,索性直接用 Go 写了一个 API 图床,另外加上个人超级喜欢 SMMS 图床的 UI,想按照那个样子写一个,无奈 CSS 渣渣,根本写不出辣么好看的样式,前几天在 V2有人发布了一个图床 传送门,这个图床的样式是模仿 SMMS 的样式,超级喜欢,于是就是用了大佬写的前端,自己造了一个基于 各类 API 的图床

前排不要脸求 Star ❤ (/ω\) 求 Star ❤ (/ω\) 求 Star ❤ (/ω\)

演示地址 AuXpI 图床

GitHub 地址 GitHub

功能 & 特色

  • 支持 web 上传图片
  • 支持 API 上传图片
  • 支持 搜狗图床,新浪图床,SMMS 图床 的图片上传
  • API 可以设置 token 可以私用,也可以选择关闭 API,只保留 web 上传
  • 可以设置是否开启新浪图床上传(因为新浪图床需要登录自己的账号)
  • 可以设置允许上传的图片最大大小 和 一次性上传的最多张数
  • 轻量级,无需数据库,配置只需要一个 json
  • 部署简单,无需繁琐 lnmp 环境,一个 命令即可起飞
  • .....

首页

管理员后台

用户后台

设置页面

总结

其实通过写这次的项目学到了不少的新东西,很多在学 php 的时候没有接触到的东西,Go 部署的方便和交叉编译真的让我很惊喜,作为一个强类型的语言,变量的描述上面更加的确切,对于内存方面的操控也更为的方便。

另外感触最深的还是 Go 的 Http 库,原生但是强大,当时写这个项目的时候,对接新浪和其它的那些 api 需要反复的提交请求,作为一个 PHPer 第一反应就是用 CURL 扩展,但是在 Go 中确实不需要的,Go 自带的 HTTP 库用起来真的爽(就是需要踩不少坑)

希望 PHPer 学一门静态语言,Go也好 Java 也好,或者其他你感谢酷 的语言,真的可以学到不少东西

感兴趣的同学可以去测试一下图片上传 AuXpI 图床

最后 还要求一下 Star (/ω\)

项目地址 GitHub

如果有问题或者想要讨论,欢迎在 Issue 中提出 ,❤

《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
讨论数量: 4

新浪图床没开放呢,还有能直接粘贴上传方便了
需要先安装bee go get -u github.com/beego/bee https://beego.me/docs/intro/

$ bee run auxpi
______
| ___ \
| |_/ /  ___   ___
| ___ \ / _ \ / _ \
| |_/ /|  __/|  __/
\____/  \___| \___| v1.10.0
2018/11/08 16:46:57 INFO     ▶ 0001 Using 'auxpi' as 'appname'
2018/11/08 16:46:57 INFO     ▶ 0002 Initializing watcher...
auxpiAll\all_easyjson.go:7:2: cannot find package "github.com/mailru/easyjson" i                 n any of:

go get -u github.com/mailru/easyjson 然后

$ bee run auxpi
______
| ___ \
| |_/ /  ___   ___
| ___ \ / _ \ / _ \
| |_/ /|  __/|  __/
\____/  \___| \___| v1.10.0
2018/11/08 16:52:59 INFO     ▶ 0001 Using 'auxpi' as 'appname'
2018/11/08 16:52:59 INFO     ▶ 0002 Initializing watcher...
auxpi/auxpiAll/e
github.com/astaxie/beego/cache
auxpi/auxpiAll
auxpi/bootstrap
auxpi/controllers
auxpi/server
auxpi/utils
auxpi/controllers/upload
auxpi/controllers/api
auxpi/routers
# auxpi/routers
routers\commentsRouter_______go_src_auxpi_controllers.go:16:13: unknown field 'Filters' in struct literal of type beego.ControllerComments
routers\commentsRouter_______go_src_auxpi_controllers.go:25:13: unknown field 'Filters' in struct literal of type beego.ControllerComments
routers\commentsRouter_______go_src_auxpi_controllers.go:34:13: unknown field 'Filters' in struct literal of type beego.ControllerComments
routers\commentsRouter_______go_src_auxpi_controllers.go:43:13: unknown field 'Filters' in struct literal of type beego.ControllerComments
routers\commentsRouter_______go_src_auxpi_controllers_upload.go:16:13: unknown field 'Filters' in struct literal of type beego.ControllerComments
routers\commentsRouter_controllers.go:16:13: unknown field 'Filters' in struct literal of type beego.ControllerComments
routers\commentsRouter_controllers.go:25:13: unknown field 'Filters' in struct literal of type beego.ControllerComments
routers\commentsRouter_controllers.go:34:13: unknown field 'Filters' in struct literal of type beego.ControllerComments
routers\commentsRouter_controllers.go:43:13: unknown field 'Filters' in struct literal of type beego.ControllerComments
routers\commentsRouter_controllers_upload.go:16:13: unknown field 'Filters' in struct literal of type beego.ControllerComments
routers\commentsRouter_controllers_upload.go:16:13: too many errors
2018/11/08 16:53:01 ERROR    ▶ 0003 Failed to build the application: # auxpi/routers
routers\commentsRouter_______go_src_auxpi_controllers.go:16:13: unknown field 'Filters' in struct literal of type beego.ControllerComments
routers\commentsRouter_______go_src_auxpi_controllers.go:25:13: unknown field 'Filters' in struct literal of type beego.ControllerComments
routers\commentsRouter_______go_src_auxpi_controllers.go:34:13: unknown field 'Filters' in struct literal of type beego.ControllerComments
routers\commentsRouter_______go_src_auxpi_controllers.go:43:13: unknown field 'Filters' in struct literal of type beego.ControllerComments
routers\commentsRouter_______go_src_auxpi_controllers_upload.go:16:13: unknown field 'Filters' in struct literal of type beego.ControllerComments
routers\commentsRouter_controllers.go:16:13: unknown field 'Filters' in struct literal of type beego.ControllerComments
routers\commentsRouter_controllers.go:25:13: unknown field 'Filters' in struct literal of type beego.ControllerComments
routers\commentsRouter_controllers.go:34:13: unknown field 'Filters' in struct literal of type beego.ControllerComments
routers\commentsRouter_controllers.go:43:13: unknown field 'Filters' in struct literal of type beego.ControllerComments
routers\commentsRouter_controllers_upload.go:16:13: unknown field 'Filters' in struct literal of type beego.ControllerComments
routers\commentsRouter_controllers_upload.go:16:13: too many errors

咋办?对go不熟悉,不支持win吗

5个月前
aimerforreimu

@lovecn routers文件夹下面除了router.go 全部删掉,然后执行

bee run auxpi

估计是因为路由是使用反射生成的原因,感谢反馈,如果想编译win 版本请参考 readme 中的交叉编译

5个月前

@aimerforreimu 成功了

$ bee run auxpi
______
| ___ \
| |_/ /  ___   ___
| ___ \ / _ \ / _ \
| |_/ /|  __/|  __/
\____/  \___| \___| v1.10.0
2018/11/08 19:53:08 INFO     ▶ 0001 Using 'auxpi' as 'appname'
2018/11/08 19:53:08 INFO     ▶ 0002 Initializing watcher...
auxpi/routers
auxpi
2018/11/08 19:53:25 SUCCESS  ▶ 0003 Built Successfully!
2018/11/08 19:53:25 INFO     ▶ 0004 Restarting 'auxpi.exe'...
2018/11/08 19:53:25 SUCCESS  ▶ 0005 './auxpi.exe' is running...
2018/11/08 19:53:25.404 [I] [parser.go:96]  generate router from comments
2018/11/08 19:53:25.407 [I] [parser.go:96]  generate router from comments
2018/11/08 19:53:25.460 [I] [asm_amd64.s:1333]  http server Running on http://:2333
5个月前

赞一个

5个月前

请勿发布不友善或者负能量的内容。与人为善,比聪明更重要!