仅需Java环境即可运行
- 配置释义
因为是上传到Github仓库,故而需要owner
、repo
,在仓库中的位置path
,以及授权用的token
。
这些都应该实现保存在jar包同目录下的app.config
文件中。举例如下:
owner = nICEnnnnnnnLee
repo = AbcTest
path = /note/hello/
token = 06495cbd3c86f38dd4b1e5a75249b14804d08tt5
- 注意事项
path
应该以/
开头,并且以/
结尾,如根目录,path = /
path
应当不包含中文等特殊字符path
在上传前可以不存在,上传文件时自动建立token
请在这里设置并获取,repo
相关权限打勾即可- 仅支持上传新文件,若路径存在同名文件,将上传失败
-
独立运行
-
嵌入第三方程序
以下为示例,
// 构造url链接 https://api.github.com/repos/:owner/:repo/contents/:path
String url = "https://api.github.com/repos/nICEnnnnnnnLee/AbcTest/contents/note/test.jpg";
// 获取想要上传的文件
File file = new File("D:\\Workspace\\sources\\pics\\test.jpg");
// 上传,并获取结果
boolean result = FileUploader.create(url, file, ":token");
LICENSE
Copyright (C) 2019 NiceLee. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.