0

I want to transfer my local folder to azure blob for that I have used this movement nuget from azure docs website link

code from section - Transfer a local directory to Blob storage works perfectly fine and upload all folder to blob but problem is all file content-type is application/octet it should take its own default content type like if its html it should uplaod html file content as text/html

What should be done? pls guide.

public static async Task TransferLocalDirectoryToAzureBlobDirectory(CloudStorageAccount account)
{
    string localDirectoryPath = GetSourcePath();
    CloudBlobDirectory blobDirectory = GetBlobDirectory(account);
    TransferCheckpoint checkpoint = null;
    DirectoryTransferContext context = GetDirectoryTransferContext(checkpoint);
    CancellationTokenSource cancellationSource = new CancellationTokenSource();
    Console.WriteLine("\nTransfer started...\nPress 'c' to temporarily cancel your transfer...\n");

    Stopwatch stopWatch = Stopwatch.StartNew();
    Task task;
    ConsoleKeyInfo keyinfo;
    UploadDirectoryOptions options = new UploadDirectoryOptions()
    {
        Recursive = true
    };

    try
    {
        task = TransferManager.UploadDirectoryAsync(localDirectoryPath, blobDirectory, options, context, cancellationSource.Token);
Neo
  • 15,491
  • 59
  • 215
  • 405
  • The [code](https://github.com/azure-samples/storage-dotnet-data-movement-library-app) for that data movement library is in GitHub, so you could modify that to set the Blob header to denote appropriate `content-type`, see this SO [answer](https://stackoverflow.com/a/62291997/14973743) – Anand Sowmithiran Jun 02 '22 at 13:54
  • 1
    Code link given in above comment is the sample app, the actual library is in this path [here](https://github.com/Azure/azure-storage-net-data-movement). Use the `BlobHttpHeaders` - [docs](https://learn.microsoft.com/en-us/dotnet/api/azure.storage.blobs.models.blobhttpheaders?view=azure-dotnet) – Anand Sowmithiran Jun 02 '22 at 14:01

0 Answers0