无需中间文件即可将Azure Blob直接上传到SFTP服务器 [英] Uploading a Azure blob directly to SFTP server without an intermediate file
本文介绍了无需中间文件即可将Azure Blob直接上传到SFTP服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将Azure blob直接上传到SFTP服务器。
I'm attempting to upload am Azure blob directly to an SFTP server.
从本地位置上传文件很简单:
It's simple to upload a file from a local location:
using (var sftp = new SftpClient(connectionInfo)){
sftp.Connect();
using (var uplfileStream = System.IO.File.OpenRead(fileName)){
sftp.UploadFile(uplfileStream, fileName, true);
}
sftp.Disconnect();
}
是否可以将Blob从Blob存储直接复制到SFTP服务器?
Is there a way to copy blobs from blob storage directly to an SFTP server?
推荐答案
-
两者结合使用
CloudBlob.OpenRead
与SftpClient.UploadFile
:
using (var blobReadStream = blockBlob.OpenRead())
{
sftp.UploadFile(blobReadStream, remotePath, true);
}
或合并 SftpClient.Create
与 CloudBlob .DownloadToStream
:
using (var sftpWriteStream = sftp.Create(remotePath))
{
blockBlob.DownloadToStream(sftpWriteStream);
}
第一种方法应相对于<$ c返回的 SftpFileStream
,相对于 SftpClient.UploadFile
已优化$ c> SftpClient.Create 。
The first approach should be a way faster in SFTP terms, as SftpClient.UploadFile
is optimized, comparing to the SftpFileStream
returned by SftpClient.Create
.
这篇关于无需中间文件即可将Azure Blob直接上传到SFTP服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文