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");
Код: Выделить всё
// 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);
It is also ok, if another extracting library suggested or another solution.
Источник: https://stackoverflow.com/questions/781 ... to-another