1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-25 12:45:18 +01:00

[Hotfix] Fix attachment download (#1841)

This commit is contained in:
Oscar Hinton 2022-02-07 15:46:20 +01:00 committed by GitHub
parent cd61c826f9
commit f56d2ecae5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 2 deletions

View File

@ -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")]

View File

@ -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);
}
}
}

View File

@ -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")