mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-04 18:10:10 +08:00
新增 上传蓝牙程序到oss服务器方法
This commit is contained in:
@@ -71,7 +71,34 @@ public class AliyunOssUploadUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 上传到阿里云(车位相机用)
|
* 上传蓝牙升级程序文件
|
||||||
|
* @param file
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String uploadBlueToothFile(MultipartFile file) {
|
||||||
|
// 生成 OSSClient
|
||||||
|
OSS ossClient = new OSSClientBuilder().build(aliyunOssConfig.getEndpoint(), aliyunOssConfig.getAccessKeyId(), aliyunOssConfig.getAccessKeySecret());
|
||||||
|
|
||||||
|
// 编码文件名
|
||||||
|
String filePathName = FileUploadUtils.extractFilename(file);
|
||||||
|
|
||||||
|
// 拼装路径
|
||||||
|
filePathName = aliyunOssConfig.getBluetoothFileHost() + "/files/" + filePathName;
|
||||||
|
try {
|
||||||
|
PutObjectResult putObjectResult = ossClient.putObject(aliyunOssConfig.getBucketName(), filePathName, file.getInputStream());
|
||||||
|
log.info("上传OSS成功, url:{}", putObjectResult.getResponse().getUri());
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
if (ossClient != null) {
|
||||||
|
ossClient.shutdown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return aliyunOssConfig.getUrl() + "/" + filePathName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车位相机图片上传到阿里云(车位相机用)
|
||||||
* @param compressedImageBytes
|
* @param compressedImageBytes
|
||||||
* @param fileName 文件名 (车位号 + 时间戳).jpg
|
* @param fileName 文件名 (车位号 + 时间戳).jpg
|
||||||
* @return
|
* @return
|
||||||
|
|||||||
Reference in New Issue
Block a user