Giter Site home page Giter Site logo

emengweb / picturegithubtool Goto Github PK

View Code? Open in Web Editor NEW

This project forked from 243286065/picturegithubtool

0.0 0.0 0.0 2.14 MB

使用github作为图床的工具,快速上传图片到github,并获取链接地址

Go 92.57% Shell 0.22% CSS 3.14% SCSS 4.07%

picturegithubtool's Introduction

PictureGithubTool

使用github作为图床的工具,快速上传图片到github,并获取链接地址。演示地址: http://47.116.197.43:8081/

运行方法

Linux下可以直接执行:

./start-all.sh

Windows下还没写启动后脚本,可以直接使用go运行:

go run service/apigw/main.go

然后就可以通过浏览器访问http://ip:8081/, ip为启动服务的主机ip,端口号可以通过修改config/web_server.go文件中的WebServerHost字段来修改,默认是8081。

使用的工具及插件

bootstrap

有名的web ui前端开发框架。 可访问https://www.bootcss.com/

bootstrap-fileinput

基于bootstrap实现的文件上传插件,示例:https://plugins.krajee.com/file-basic-usage-demo

bootstrap-select

基于bootstrap实现的下拉搜索插件,官网:https://developer.snapappointments.com/bootstrap-select/

运行效果

image

image

实现逻辑

  • 主要是使用github v3 api。这里使用golang开发主要是为了锻炼,完全可以只用js实现。

  • 本身工具是完全的客户端程序,但是因为对bootstrap-fileinput插件,如何直接上传到github没弄清楚,所以暂时还是有服务端,客户端先通过bootstrap-fileinput上传图片到服务端,服务端再上传到github.

注意事项

  • 敬告:github已禁用用户名和密码的认证方式,改用access token的方式,详见官方文档

注意创建access token的时候开通仓库权限

  • 如果上传失败可能的原因:

    • github暂时无法连接,你可以重新登录试试;
    • 没有选择仓库;
    • 路径填写不正确,可以填写例如"a/b",这样会将文件存放在'a/b'目录。
  • 请注意仓库不要使用私有仓库,这会导致未认证时无法访问;也请注意不要轻易删除存放图片的仓库里的文件。

  • 实现比较仓促,可能会有很多bug或者错误逻辑。

版本说明

  • v1.0: 支持基础的图片上传功能;
  • v1.1: 支持粘贴板粘贴文件.(每次仍只允许最多上传1个文件,因此粘贴板粘贴的文件可能第一次上传失败,可以刷新重新上传).
  • v1.2:改用access token认证。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.