各位老哥,请赐予我一道 curl post类,助我降妖伏魔吧

兽兽 2020-06-16 04:51:10
java小白,妄想用 curl post 数据流到 github仓库


奈何小白一枚 无从下手,

/*
zipFile controller传来的 图片文件
*/


    @Override
public CommonRes index(MultipartFile zipFile, String valuess) {
String fileName = UUID.randomUUID().toString().replace("-", "");

Date date = new Date();
String path=new SimpleDateFormat("yyyy/MM/dd/").format(date);
//如果不存在,创建文件夹
File f = new File(path);
if(!f.exists()){
f.mkdirs();
}

String fileSuffix = getFileSuffix(zipFile);
if (fileSuffix != null) { // 拼接后缀
fileName += fileSuffix;
}

File targetFile = new File(path + File.separator + fileName);
FileOutputStream fileOutputStream = null;

fileOutputStream = new FileOutputStream(targetFile);
IOUtils.copy(zipFile.getInputStream(), fileOutputStream);


}



IOUtils.copy 应该是写入硬盘的吧,

然后怎么把这数据 再post到GitHub仓库,

或者说 post到自己的 另一个图片接口



老哥们麻烦发下post 类 用用吧

对了
要设置header头的

"User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36",
...全文
1881 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
兽兽 2020-06-17
  • 打赏
  • 举报
回复
谢谢大佬,我在github上找到了一个, https://github.com/nICEnnnnnnnLee/FileUploader4Github/blob/master/src/nicelee/github/upload/FileUploader.java 有需要的同学可以参考
兽兽 2020-06-16
  • 打赏
  • 举报
回复
老哥 有中文 文档吗,小学生,看不懂英文, gg翻译的也是 牛头不对马嘴,好难懂, 好像直接就能 用git仓库?
tianfang 2020-06-16
  • 打赏
  • 举报
回复
封装好的用 jgit啊 https://www.eclipse.org/jgit/ https://doc.nuxeo.com/blog/jgit-example/
兽兽 2020-06-16
  • 打赏
  • 举报
回复
引用 1 楼 rumlee 的回复:
httpclient
我想要封装好的, 只要传入地址和图片即可
rumlee 2020-06-16
  • 打赏
  • 举报
回复
httpclient

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧