Давно работаю программистом VBA, погружаюсь в мир C/C# и Azure. У меня есть код, который загружает PDF-файлы счетов в большой объект в Azure. Мне приходится добавлять теги при загрузке каждого PDF-файла. Я искал неделю, но не смог найти код, который мог бы сделать то, что мне кажется простым.
Буду очень признателен за любые советы.
Спасибо.
Код: Выделить всё
using Azure.Storage.Blobs;
using Azure.Storage.Blobs.Models;
using System.Diagnostics;
using System.IO;
using System.Reflection.Metadata;
using static System.Net.WebRequestMethods;
using static System.Windows.Forms.Design.AxImporter;
namespace UploadDealerDocuments
{
class program
{
static string connectionString = "DefaultEndpointsProtocol=https;AccountName=###;AccountKey=###;EndpointSuffix=core.windows.net";
static string containerName = "smi-statements-invoices-staging";
static void Main(string[] args)
{
BlobServiceClient blobServiceClient = new BlobServiceClient(connectionString);
BlobContainerClient containerClient = blobServiceClient.CreateBlobContainer(containerName);
string str = "";
var files = Directory.GetFiles(@"N:\Azure\invoices\");
foreach (var file in files)
{
str = Path.GetFileName(file);
str = str.Replace("_", "/");
Console.WriteLine(str);
using (MemoryStream stream = new MemoryStream(System.IO.File.ReadAllBytes(file)))
{
containerClient.UploadBlob(str, stream);
}
str = @"N:\Azure\Invoices\Uploaded\" + Path.GetFileName(file);
System.IO.File.Move(@"N:\Azure\Invoices\" + Path.GetFileName(file), str);
Console.WriteLine(file + "Uploaded!");
}
Console.WriteLine("Files Uploaded!");
Console.Read();
}
}
}
Код: Выделить всё
var Tags = new Dictionary {
{ "file_date", "2022-10-03" },
{ "title", "some title" }
};
_ = await blobClient.UploadAsync(str, options);
Код: Выделить всё
BlobUploadOptions options = new BlobUploadOptions
{
Tags = new Dictionary {
{ "name", "myBlob" },
{ "type", "blobTrigger" },
{ "direction", "in" },
{ "path", "path1/path2/name" },
{ "connection", "blob_STORAGE" }
}
};
_ = await blobClient.UploadAsync(str, options);
Источник: https://stackoverflow.com/questions/743 ... ng-c-sharp
Мобильная версия