FtpWebRequest + Windows Azure = not working?

爷,独闯天下 提交于 2019-12-11 15:35:12

问题


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

I am doing this 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?


回答1:


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




回答2:


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! :-)




回答3:


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);
    }


来源:https://stackoverflow.com/questions/7456806/ftpwebrequest-windows-azure-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!