|
|
@@ -95,6 +95,18 @@ export class MinioService {
|
|
|
return `${protocol}://${process.env.MINIO_HOST}${port}/${bucketName}/${fileKey}`;
|
|
|
}
|
|
|
|
|
|
+ // 生成预签名文件访问URL(用于私有bucket)
|
|
|
+ async getPresignedFileUrl(bucketName: string, fileKey: string, expiresInSeconds = 3600) {
|
|
|
+ try {
|
|
|
+ const url = await this.client.presignedGetObject(bucketName, fileKey, expiresInSeconds);
|
|
|
+ logger.db(`Generated presigned URL for ${bucketName}/${fileKey}, expires in ${expiresInSeconds}s`);
|
|
|
+ return url;
|
|
|
+ } catch (error) {
|
|
|
+ logger.error(`Failed to generate presigned URL for ${bucketName}/${fileKey}:`, error);
|
|
|
+ throw error;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 创建分段上传会话
|
|
|
async createMultipartUpload(bucketName: string, objectName: string) {
|
|
|
try {
|