将文件从 Blob 存储发送到 FTP 服务器

问题描述 投票:0回答:1

我在工作中使用 DataFactory。

我正在考虑将文件从 Blob 存储传输到本地 FTP 服务器,但是有没有好的方法来实现它?

当我研究它时,我发现了逻辑应用程序、Azure Functions 和自定义活动,但我想知道是否有更简单的方法来实现它......

azure-data-factory
1个回答
0
投票

根据this,我们无法直接使用ADF将文件从blob存储写入FTP服务器。您可以利用 Azure Functions 将数据从 Azure Blob 存储复制到本地 FTP 服务器。

  • 以流形式获取 Azure 文件[由 Azure Functions 为您处理]
  • 使用WebClient上传Stream

您可以使用以下代码:

public void UploadStreamToFtp(Stream file, string targetFilePath)
{
    using (MemoryStream ms = new MemoryStream())
    {
        // As MemoryStream already handles ToArray(), copy the Stream to the MemoryStream
        file.CopyTo(ms);

        using (WebClient client = new WebClient())
        {
            // Use login credentials if required
            client.Credentials = new NetworkCredential("username", "password");

            // Upload the stream as Data with the STOR method call
            // targetFilePath is a fully qualified filepath on the FTP, e.g. ftp://targetserver/directory/filename.ext
            client.UploadData(targetFilePath, WebRequestMethods.Ftp.UploadFile, ms.ToArray());
        }
    }
}

欲了解更多信息,您可以参考这个SO答案

© www.soinside.com 2019 - 2024. All rights reserved.