public Long Upload(String fileName, File file, Long point) {
OSS ossClient = new OSSClientBuilder().build(ossConfig.getRegion().concat(".aliyuncs.com"),
ossConfig.getAccessKeyId(),
ossConfig.getAccessKeySecret());
ObjectMetadata meta = new ObjectMetadata();
meta.setContentType("text/csv");
meta.setCacheControl("no-cache");
meta.setHeader("Pragma", "no-cache");
//对真正文件名称进行base64编码
String base64FileName = new String(Base64.getEncoder().encode(fileName.getBytes(StandardCharsets.UTF_8)));
//设置下载文件的名称
meta.setContentDisposition(String.format(fileName, base64FileName));
AppendObjectRequest appendObjectRequest = new AppendObjectRequest(ossConfig.getBucketPrivate(),
fileName, file, meta);
appendObjectRequest.setPosition(point);
AppendObjectResult appendObjectResult = ossClient.appendObject(appendObjectRequest);
// 关闭OSSClient。
ossClient.shutdown();
return appendObjectResult.getNextPosition();
}
假如我的博客对你有用,请你关注我一下,告诉我你来过,你的关注是我前进的动力,希望更多的人记录自己的问题,去帮助别人更是帮助自己避免再次出现这样那样的问题,谢谢你的来过!