Извлеките файл tar.gz из хранилища BLOB-объектов и загрузите извлеченный результат в другое хранилище BLOB-объектов.C#

Место общения программистов C#
Гость
Извлеките файл tar.gz из хранилища BLOB-объектов и загрузите извлеченный результат в другое хранилище BLOB-объектов.

Сообщение Гость »


I have this code that gets a blob storage file, extract it, it works when I test saving the result on my computer.
Now in stead of saving the file on local computer, I want to upload the extracted result to another blob storage. My challenge relays on how can I extract the results as bytes or stream so I can upload, I did try this, I do not get errors, but the blob is 0 byte. Any advice appreciated.

Код: Выделить всё

var blobEndPointSrc = "https://storageaccountname.blob.core.windows.net/data-source-raw?etc...";
var blobContainerClientSrc = GetBlobServiceClientSAS(blobEndPointSrc);
var blobClientSrc = blobContainerClientSrc.GetBlobClient("file.tar.gz");
var blobDownloadInfo = blobClientSrc.OpenRead();
using Stream gzipStream = new GZipInputStream(blobDownloadInfo);

// test on local drive and works.
using var tarArchive = TarArchive.CreateInputTarArchive(gzipStream);
tarArchive.ExtractContents(@"D:\file");
Now trying to take the results and upload to blob stroage:

Код: Выделить всё

// using var tarArchive = TarArchive.CreateInputTarArchive(gzipStream);
// tarArchive.ExtractContents(@"D:\file");

var tarBuffer = TarBuffer.CreateInputTarBuffer(gzipStream);
Stream result = new MemoryStream();
TarBuffer.CreateOutputTarBuffer(result );

var blobEndPointDst = = "https://storageaccountname2.blob.core.windows.net/data-source-raw?etc...";
var blobContainerClientDst = GetBlobServiceClientSAS(blobEndPointDst);
var blobClientDst = blobContainerClient1.GetBlobClient("extracted_file");
blobClientDst.Upload(result, true);
All blob code works fine for both upload and download. But the conversion of extract results, ending giving 0 byte in the uploaded file.
It is also ok, if another extracting library suggested or another solution.


Источник: https://stackoverflow.com/questions/781 ... to-another

Вернуться в «C#»