我正在尝试将azure blob文件上载到嵌套文件夹结构,如下所示:
Blob Storage snapshot
我能够成功地上传文件到父容器,这是“testblobupload”。
下面是我的代码,可能看起来很大的块,真的很抱歉:
var containerNameToUploadTheFile = applyConfirmPriceConfig.AzureBlobStorageContainerNameConfig; // Default container name where file will be saved.
//Azure Blob Storage Temp Storage Container
var connectionString = applyConfirmPriceConfig.AzureBlobStorageContainerConnectionString;
var serviceClient = new BlobServiceClient(connectionString);
containerClient = serviceClient.GetBlobContainerClient(containerNameToUploadTheFile);
var id = eventObject.Id;
var sbmessage = new ServiceBusMessage();
sbmessage.MessageId = eventObject.Id.ToString();
sbmessage.Subject = eventObject.GetType().Name.Replace(ServiceBusConstants.IntegrationEventSuffix, string.Empty).Trim();
BlobUploadOptions options = new BlobUploadOptions
{
TransferOptions = new StorageTransferOptions
{
// Set the maximum number of workers that
// may be used in a parallel transfer.
MaximumConcurrency = 20,
// Set the maximum length of a transfer to 5MB.
// Set the maximum length of a transfer to 262144 = 256KB. This is service bus message size in standard
MaximumTransferSize = 0x40000, //50 * 1024,// * 1024,
InitialTransferLength = 0x40000,
},
HttpHeaders = new BlobHttpHeaders { ContentType = "application/json" }
};
fileName = $"{$"{DateTime.UtcNow:yyyyMMddHHMM}"}_{sbmessage.Subject}_{sbmessage.MessageId}";
var memorystream = new MemoryStream(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(eventObject)));
BlobClient blobClient = containerClient.GetBlobClient($"{$"{DateTime.UtcNow:yyyyMMdd}"}/{fileName}");
await blobClient.UploadAsync(memorystream, options);
}
我尝试将容器名称更改为“testblobupload/TransactionalData/BACKTRACK”,但不起作用。
请给我建议和指导。
1条答案
按热度按时间zf9nrax11#
尝试更改以下代码行:
至