static Map<String, String> contentTypeMap;
//以下几个参数值必填,参考文章最后文档
static String endpoint = "";
static String accessKeyId = "";
static String accessKeySecert = "";
static String bucketName = "";
//根据自己上传文件类型可自行添加
static {
contentTypeMap = new HashMap<>();
contentTypeMap.put("html", "text/html");
contentTypeMap.put("htm", "text/html");
contentTypeMap.put("js", "application/x-javascript");
contentTypeMap.put("css", "text/css");
contentTypeMap.put("gif", "image/gif");
contentTypeMap.put("jpg", "image/jpeg");
contentTypeMap.put("jpeg", "image/jpeg");
contentTypeMap.put("png", "image/png");
}
/**
* 上传单个文件到OSS
* @param file 要上传的文件File对象
* @param objName 上传后的文件名,包含文件夹,比如 game/game/test.txt
*
java实现将本地文件上传至阿里oss云
最新推荐文章于 2023-08-08 21:23:39 发布