mirror of
https://github.com/bitwarden/mobile
synced 2026-01-04 17:43:17 +00:00
attachments on view page abd device actions
This commit is contained in:
@@ -35,5 +35,6 @@ namespace Bit.Core.Abstractions
|
||||
Task UpdateLastUsedDateAsync(string id);
|
||||
Task UpsertAsync(CipherData cipher);
|
||||
Task UpsertAsync(List<CipherData> cipher);
|
||||
Task<byte[]> DownloadAndDecryptAttachmentAsync(AttachmentView attachment, string organizationId);
|
||||
}
|
||||
}
|
||||
@@ -9,5 +9,6 @@
|
||||
public static string DefaultUriMatch = "defaultUriMatch";
|
||||
public static string DisableAutoTotpCopyKey = "disableAutoTotpCopy";
|
||||
public static string EnvironmentUrlsKey = "environmentUrls";
|
||||
public static string LastFileCacheClearKey = "lastFileCacheClear";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,5 +20,17 @@ namespace Bit.Core.Models.View
|
||||
public string SizeName { get; set; }
|
||||
public string FileName { get; set; }
|
||||
public SymmetricCryptoKey Key { get; set; }
|
||||
|
||||
public long FileSize
|
||||
{
|
||||
get
|
||||
{
|
||||
if(!string.IsNullOrWhiteSpace(Size) && long.TryParse(Size, out var s))
|
||||
{
|
||||
return s;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -678,6 +678,27 @@ namespace Bit.Core.Services
|
||||
await DeleteAttachmentAsync(id, attachmentId);
|
||||
}
|
||||
|
||||
public async Task<byte[]> DownloadAndDecryptAttachmentAsync(AttachmentView attachment, string organizationId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var response = await _httpClient.GetAsync(new Uri(attachment.Url));
|
||||
if(!response.IsSuccessStatusCode)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var data = await response.Content.ReadAsByteArrayAsync();
|
||||
if(data == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var key = attachment.Key ?? await _cryptoService.GetOrgKeyAsync(organizationId);
|
||||
return await _cryptoService.DecryptFromBytesAsync(data, key);
|
||||
}
|
||||
catch { }
|
||||
return null;
|
||||
}
|
||||
|
||||
// Helpers
|
||||
|
||||
private async Task ShareAttachmentWithServerAsync(AttachmentView attachmentView, string cipherId,
|
||||
|
||||
Reference in New Issue
Block a user