diff --git a/src/Api/Controllers/CiphersController.cs b/src/Api/Controllers/CiphersController.cs index b301ad8ff..f80755300 100644 --- a/src/Api/Controllers/CiphersController.cs +++ b/src/Api/Controllers/CiphersController.cs @@ -717,7 +717,7 @@ namespace Bit.Api.Controllers var userId = _userService.GetProperUserId(User).Value; var cipher = await _cipherRepository.GetByIdAsync(new Guid(id), userId); var result = await _cipherService.GetAttachmentDownloadDataAsync(cipher, attachmentId); - return new AttachmentResponseModel(result.Id, result.Data, result.Cipher, _globalSettings); + return new AttachmentResponseModel(result); } [HttpPost("{id}/attachment/{attachmentId}/share")] diff --git a/src/Api/Controllers/EmergencyAccessController.cs b/src/Api/Controllers/EmergencyAccessController.cs index d28fe3b78..afb1de61b 100644 --- a/src/Api/Controllers/EmergencyAccessController.cs +++ b/src/Api/Controllers/EmergencyAccessController.cs @@ -175,7 +175,7 @@ namespace Bit.Api.Controllers var user = await _userService.GetUserByPrincipalAsync(User); var result = await _emergencyAccessService.GetAttachmentDownloadAsync(new Guid(id), cipherId, attachmentId, user); - return new AttachmentResponseModel(result.Id, result.Data, result.Cipher, _globalSettings); + return new AttachmentResponseModel(result); } } } diff --git a/src/Api/Models/Response/AttachmentResponseModel.cs b/src/Api/Models/Response/AttachmentResponseModel.cs index 4edd8eae3..5e8c88574 100644 --- a/src/Api/Models/Response/AttachmentResponseModel.cs +++ b/src/Api/Models/Response/AttachmentResponseModel.cs @@ -11,6 +11,16 @@ namespace Bit.Api.Models.Response { public class AttachmentResponseModel : ResponseModel { + public AttachmentResponseModel(AttachmentResponseData data) : base("attachment") + { + Id = data.Id; + Url = data.Url; + FileName = data.Data.FileName; + Key = data.Data.Key; + Size = data.Data.Size; + SizeName = CoreHelpers.ReadableBytesSize(data.Data.Size); + } + public AttachmentResponseModel(string id, CipherAttachment.MetaData data, Cipher cipher, IGlobalSettings globalSettings) : base("attachment")