diff --git a/note.md b/note.md new file mode 100644 index 00000000..6f31fd67 --- /dev/null +++ b/note.md @@ -0,0 +1,2 @@ +Tài khoản: hongochai10@icloud.com +Mật Khẩu: Velik@2026 \ No newline at end of file diff --git a/services/storage-service-net/src/StorageService.API/Application/Commands/UploadFileCommandHandler.cs b/services/storage-service-net/src/StorageService.API/Application/Commands/UploadFileCommandHandler.cs index 1866a703..dce5f6e8 100644 --- a/services/storage-service-net/src/StorageService.API/Application/Commands/UploadFileCommandHandler.cs +++ b/services/storage-service-net/src/StorageService.API/Application/Commands/UploadFileCommandHandler.cs @@ -52,8 +52,9 @@ public class UploadFileCommandHandler : IRequestHandler + /// EN: Generate object key with path prefix based on access level. + /// VI: Tạo object key với path prefix theo access level. + /// + /// + /// EN: Path structure: + /// - public/{userId}/{date}/{fileId}_{filename} → Publicly accessible + /// - private/{userId}/{date}/{fileId}_{filename} → Requires pre-signed URL + /// - shared/{userId}/{date}/{fileId}_{filename} → Access controlled by sharing rules + /// VI: Cấu trúc path: + /// - public/{userId}/{date}/{fileId}_{filename} → Truy cập công khai + /// - private/{userId}/{date}/{fileId}_{filename} → Yêu cầu pre-signed URL + /// - shared/{userId}/{date}/{fileId}_{filename} → Kiểm soát bởi quy tắc chia sẻ + /// + private static string GenerateObjectKey(string userId, string fileName, FileAccessLevel accessLevel) { + var prefix = accessLevel switch + { + FileAccessLevel.Public => "public", + FileAccessLevel.Shared => "shared", + _ => "private" + }; + var timestamp = DateTime.UtcNow.ToString("yyyyMMdd"); var uniqueId = Guid.NewGuid().ToString("N")[..8]; var safeFileName = SanitizeFileName(fileName); - return $"{userId}/{timestamp}/{uniqueId}_{safeFileName}"; + return $"{prefix}/{userId}/{timestamp}/{uniqueId}_{safeFileName}"; } private static string SanitizeFileName(string fileName) @@ -119,3 +141,4 @@ public class UploadFileCommandHandler : IRequestHandler