2021-03-29 17:45:04 +03:00
|
|
|
using System;
|
|
|
|
using System.Net.Http;
|
|
|
|
using System.Threading.Tasks;
|
2021-04-21 23:27:14 +03:00
|
|
|
using Bit.Core.Models.Domain;
|
2021-03-29 17:45:04 +03:00
|
|
|
|
|
|
|
namespace Bit.Core.Services
|
|
|
|
{
|
|
|
|
public class BitwardenFileUploadService
|
|
|
|
{
|
|
|
|
public BitwardenFileUploadService(ApiService apiService)
|
|
|
|
{
|
|
|
|
_apiService = apiService;
|
|
|
|
}
|
|
|
|
|
|
|
|
private readonly ApiService _apiService;
|
|
|
|
|
2021-04-21 23:27:14 +03:00
|
|
|
public async Task Upload(string encryptedFileName, EncByteArray encryptedFileData, Func<MultipartFormDataContent, Task> apiCall)
|
2021-03-29 17:45:04 +03:00
|
|
|
{
|
|
|
|
var fd = new MultipartFormDataContent($"--BWMobileFormBoundary{DateTime.UtcNow.Ticks}")
|
|
|
|
{
|
2021-04-21 23:27:14 +03:00
|
|
|
{ new ByteArrayContent(encryptedFileData.Buffer), "data", encryptedFileName }
|
2021-03-29 17:45:04 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
await apiCall(fd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|