I am trying to save a file downloaded from an SFTP site using the WinSCP .NET library, and then save it Azure Blob storage. I don't want to use CloudBlobContainer
as it is deprecated. I keep getting the error message:
Offsets with value of non-zero are not supported when executing ....
await blobClient.UploadAsync
using WinSCP;
using Microsoft.Azure.Storage.Blob;
BlobServiceClient blobServiceClient = new BlobServiceClient(_connectionString);
BlobContainerClient blobContainerClient =
blobServiceClient.GetBlobContainerClient(containername);
BlobClient blobClient = blobContainerClient.GetBlobClient(filename);
using (Session session = new Session())
{
session.Open(sessionOptions);
string remotePath = "/myfile.zip";
using (System.IO.Stream stream = session.GetFile(remotePath, transferOptions))
{
await blobClient.UploadAsync(stream,new BlobHttpHeaders
{
ContentType = "application/zip"
}
);
};
I am able to write the stream to disk.
using (var fileStream = new FileStream(newfile, FileMode.Create, FileAccess.Write))
{
stream.CopyTo(fileStream);
}