将图片自动上传到 GitHub, 返回图片 URL

2016-08-14 12:35:29 +08:00
 huntzhan
项目地址: https://github.com/huntzhan/img2url
13871 次点击
所在节点    Python
78 条回复
inoris
2016-08-14 14:50:20 +08:00
看起来是开一个 repo 用来放图的,感觉不太友好。 GitHub 自己有一个图床接口,在 Issues 页里可以拖拽图片上传,接口是 https://github.com/upload/policies/assets ,不妨试试?
huntzhan
2016-08-14 15:52:56 +08:00
@majinjing3 已经加上了, 支持自定义 branch 与 path.
huntzhan
2016-08-14 15:55:20 +08:00
@inoris 你说的是 https://developer.github.com/v3/repos/releases/ 这个接口吧? 似乎这个接口也不适合用来做这个事情. 之前我打算用 issue 的自动拖图片上传的接口, 调研的结论是 GitHub 没有开放这个接口, 所以才直接用 contents 的 API 的.
hellopython
2016-08-14 16:46:44 +08:00
Example of .img2url.yml:

token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
user: img2url-testing
repo: img2url-testing-travisci
proxies:
https: socks5://127.0.0.1:1080
Required fields:

token: Personal access tokens of your GitHub account. If you don't have one, click "Generate new token" and select the "repo" scope, then record the generated token.
user: Account of GitHub.
repo: The repository to store images.

这个怎么填写啊?
7sDream
2016-08-14 17:06:58 +08:00
感觉吧,并不是很道德,毕竟 Github 是为了合作码代码,而不是作为网盘或图床。

Github 使用协议的 General Conditions 第 12 条: If your bandwidth usage significantly exceeds the average bandwidth usage (as determined solely by GitHub) of other GitHub customers, we reserve the right to immediately disable your account or throttle your file hosting until you can reduce your bandwidth consumption.

所以还是注意下吧。

如果有人去 https://github.com/contact/report-abuse 报告滥用的话可能会被封的。

善意提醒一下。
huntzhan
2016-08-14 17:11:11 +08:00
@7sDream 十分感谢, 之前没有注意到这一点. 我看下是否有解决方案...
huntzhan
2016-08-14 17:13:22 +08:00
@hellopython 在 HOME 下面创建一个 `.img2url.yml`, 然后按照 YAML 的语法写就可以了. 直接把 example 复制过去, 改下 `token`, `user`, `repo` 的值就可以用了.
we000
2016-08-14 17:23:47 +08:00
@huntzhan 解决方案就是删除项目, 确实是 abuse 了
huntzhan
2016-08-14 17:27:17 +08:00
@7sDream https://github.com/rgrove/rawgit/wiki/Frequently-Asked-Questions#what-will-happen-if-i-send-large-amounts-of-traffic-to-a-rawgitcom-development-url
我觉得已经套上了一层 CDN, bandwidth 已经不是问题了. 我猜这个跟使用 GitHub host personal static website 是一个性质的, I'm not sure.
huntzhan
2016-08-14 17:27:28 +08:00
@we000 同上
20150517
2016-08-14 17:36:48 +08:00
我之前看到有人开发了个类似的,不过是上床新浪微博图床的,还是用那个比较好,github 国内毕竟慢
hellopython
2016-08-14 17:38:53 +08:00
@huntzhan 好的,谢谢,我是在 windows7 版本装的 python2.7 ,然后 pip 装的 img2url ,在 DOS 界面无法成功上传
.img2url.yml 内容
token 填的新建的
user Github 名字
repo 填写的新建的 photos
huntzhan
2016-08-14 17:43:54 +08:00
@hellopython ...十分抱歉, 我手上没有 windows 的系统, 我试下用虚拟机测试一下. 字段的描述是对的.
cszhiyue
2016-08-14 18:08:23 +08:00
@huntzhan 确实是滥用了。建议楼主删除这个 repos 。
XhstormR
2016-08-14 18:09:05 +08:00
github 仓库大小是有限的,不过不知道是多大。
cszhiyue
2016-08-14 18:18:35 +08:00
llbbzh
2016-08-14 19:55:47 +08:00
这就是典型的**滥用**啊……

为何不用新浪微博呢,微博就是拿来分享图片的
ZE3kr
2016-08-14 19:58:25 +08:00
@7sDream 其实 GitHub 有 Git LFS ,随便存多大视频、图片,但是要交钱哦。 @XhstormR
ZE3kr
2016-08-14 20:00:25 +08:00
https://help.github.com/articles/billing-plans-for-git-large-file-storage/ 用这个就不算滥用了吧,要是有需要就是要用 Git 管理那些图片呢,还是很有用的。
huntzhan
2016-08-14 20:10:35 +08:00
@llbbzh ...我发邮件去问下

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/299197

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX