2017-03-14 14:31
@HalcyonDays public static String uploadImage(UploadFile upFile){
String dir = "image/temp/";
String forder = UUID.randomUUID().toString();
File file = upFile.getFile();
String fileName = file.getName();
// 创建OSSClient实例
OSSClient ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret);
// 上传文件 PutObjectResult result =
ossClient.putObject(bucket, dir+forder+"/"+fileName, file);
// 关闭client
ossClient.shutdown();
//删除存在本地的图片
file.delete();
//返回图片访问url
return allEndPoint+dir+forder+"/"+URLEncoder.encode(fileName);
}