Загрузить файл из файловой системы < /li>
Изменить файл путем внедрения пользовательского идентификатора < /li>
Отправить измененный файл на внешнюю систему с помощью http. < /li>
< /ol>
Текущая реализация: < /p>
Код: Выделить всё
public async Task EmbedIdAndSendAsync(string filePath, string id, HttpClient httpClient)
{
using (Stream stream = File.OpenRead(filePath))
using (PdfDocument pdf = new PdfDocument(stream))
using (MemoryStream modifiedStream = new MemoryStream())
{
pdf.EmbedId(id);
pdf.WriteTo(modifiedStream);
modifiedStream.Position = 0;
await httpClient.PostAsync(
"files/upload",
new MultipartFormDataContent {
{ new StringContent(id), "file[id]" },
{ new StreamContent(modifiedStream), "file[stream]", Path.GetFileName(filePath) }
}
);
}
}
Подробнее здесь: https://stackoverflow.com/questions/794 ... httpclient
Мобильная версия