feat(sis):

- 图像库图片改为通过ossId获取
- SisPersonLibImg 字段 imgUrl 更改为 imgOssId,类型同步更改
- 移除SisDeviceManage 中的 accessControlId 字段
This commit is contained in:
2025-07-01 17:10:04 +08:00
parent d2638de4e4
commit 9a1a87800f
16 changed files with 116 additions and 30 deletions

View File

@@ -265,6 +265,37 @@ public class OssClient {
}
}
/**
* 下载文件从 Amazon S3 到 byte[]
*
* @param key 文件在 Amazon S3 中的对象键
* @return byte[] 返回下载的字节数组
* @throws OssException 如果下载失败,抛出自定义异常
*/
public byte[] downloadToByteArray(String key) {
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
// 构建下载请求
DownloadRequest<ResponseInputStream<GetObjectResponse>> downloadRequest = DownloadRequest.builder()
// 文件对象
.getObjectRequest(y -> y.bucket(properties.getBucketName())
.key(key)
.build())
.addTransferListener(LoggingTransferListener.create())
// 使用订阅转换器
.responseTransformer(AsyncResponseTransformer.toBlockingInputStream())
.build();
// 使用 S3TransferManager 下载文件
Download<ResponseInputStream<GetObjectResponse>> responseFuture = transferManager.download(downloadRequest);
// 输出到流中
try (ResponseInputStream<GetObjectResponse> responseStream = responseFuture.completionFuture().join().result()) { // auto-closeable stream
responseStream.transferTo(out); // 阻塞调用线程 blocks the calling thread
}
return out.toByteArray();
} catch (Exception e) {
throw new OssException("文件下载失败,错误信息:[" + e.getMessage() + "]");
}
}
/**
* 删除云存储服务中指定路径下文件
*