开发者

FtpWebRequest + Windows Azure = not working?

开发者 https://www.devze.com 2023-04-05 08:43 出处:网络
Is it possible download data on Windows Azure via FtpWebRequest (ASP.NET/C#)? I am doing this开发者_Go百科 currently and not sure if my problem is that FtpWebRequest is in general not working as expe

Is it possible download data on Windows Azure via FtpWebRequest (ASP.NET/C#)?

I am doing this开发者_Go百科 currently and not sure if my problem is that FtpWebRequest is in general not working as expected, or if I have a different failure..

Has sb. did this before?


If you're talking about Windows Azure Storage, then definitely not. FTP is not supported.

If you're working with Compute roles, you could write something to support this, but it's DIY, a la: http://blog.maartenballiauw.be/post/2010/03/15/Using-FTP-to-access-Windows-Azure-Blob-Storage.aspx


I could solve my problem doing the ftp-request with FTPLib. This means: You can copy/load files to azure or to an external source! :-)


Make this working also with AlexFTPS , you just need to add StartKeepAlive.

  try
    {
        string fileName = Path.GetFileName(this.UrlString);
        Uri uri = new Uri(this.UrlString);

        string descFilePath = Path.Combine(this.DestDir, fileName);

        using (FTPSClient client = new FTPSClient())
        {
            // Connect to the server, with mandatory SSL/TLS 
            // encryption during authentication and 
            // optional encryption on the data channel 
            // (directory lists, file transfers)
            client.Connect(uri.Host,
                           new NetworkCredential("anonymous",
                                                 "name@email.com"),
                                                 ESSLSupportMode.ClearText
            );
            client.StartKeepAlive();
            // Download a file
            client.GetFile(uri.PathAndQuery, descFilePath);
            client.StopKeepAlive();
            client.Close();
        }

    }
    catch (Exception ex)
    {
        throw new Exception("Failed to download", ex);
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号