runtime icon indicating copy to clipboard operation
runtime copied to clipboard

ASP.NET Core 1.0 - FTP upload files

Open findulov opened this issue 10 years ago • 14 comments

Hi, I'm trying to upload files to a FTP server. I've tried using old piece of code I've used ASP.NET MVC 5 but DNX Core does not see to provide FtpWebRequest class for FTP manipulation. One workaround has come to my mind to use HttpClient with external Web service (WebAPI 2) which will upload my files, but I would have to maintain two applications and I don't like this approach... So is there any other approach I could use and I'm apparently missing? Thanks!

ftp

findulov avatar Apr 01 '16 15:04 findulov

I believe FtpWebRequest is not available on .Net Core. WebRequest on .Net Core is just a wrapper around HttpCLient and it does not support FTP. I also didn't find any Core-compatible packages for FTP after a cursory search of NuGet.

The confusing thing is that if you remove the cast to FtpWebRequest, and don't set FtpWebRequest-specific properties, then WebRequest.Create() succeeds (I think it's because of this line), but then fails when you actually try to retrieve the request. Is there any reason to pretend FTP is supported like this?

svick avatar Apr 01 '16 22:04 svick

These lines in WebRequest.cs should have never been ported to CoreFx:

prefixList.Add(new WebRequestPrefixElement("file:", new HttpRequestCreator())); 
prefixList.Add(new WebRequestPrefixElement("ftp:", new HttpRequestCreator())); 

CoreFx doesn't support file: or ftp: schemes for WebRequest classes. Only the HttpWebRequest is supported on CoreFx.

We will submit a PR to fix this.

davidsh avatar Apr 02 '16 01:04 davidsh

cc: @stephentoub

davidsh avatar Apr 02 '16 01:04 davidsh

@davidsh Any plan to support it by RTM?

MaximRouiller avatar Apr 05 '16 13:04 MaximRouiller

Any plan to support it by RTM?

What do you mean by "it"? If you mean "we will support FtpWebRequest class in CoreFx", the answer is no. We have no plans to do that. There are better architectures and coding patterns for Ftp than the 'FtpWebRequest' pattern. There are several 3rd party libraries (FtpClient) out there.

davidsh avatar Apr 05 '16 14:04 davidsh

Not FtpWebRequest per se. Just 'FTP'. Is it something the team want to spend time on or is it a scenario where the decision has been made to rely on 3rd party libraries?

MaximRouiller avatar Apr 05 '16 14:04 MaximRouiller

Currently Ftp is not a priority. And there are many 3rd party libraries to fill the gap right now.

davidsh avatar Apr 05 '16 16:04 davidsh

@davidsh Are you aware of any third party FTP libraries that support .Net Core?

svick avatar Apr 05 '16 17:04 svick

I am not aware of any specific libraries that target .NET Core. But we haven't really been looking lately. As I mentioned, Ftp is not a priority for the team right now.

davidsh avatar Apr 05 '16 17:04 davidsh

Thanks for the clarification @davidsh

MaximRouiller avatar Apr 05 '16 17:04 MaximRouiller

Does anyone know which ftp utility can be used with .NETCore RC2?

maliu1970 avatar Sep 06 '16 20:09 maliu1970

there are many 3rd party libraries to fill the gap right now.

I am not aware of any specific libraries that target .NET Core.

Eh? :)

Here is one potential: CoreFTP, although i have yet to use it.

stephendrew avatar Mar 09 '17 13:03 stephendrew

What are these better architectures and patterns you spreak of?

sharpcoder28 avatar Jun 20 '17 18:06 sharpcoder28

FtpWebRequest is supported now as part of .NET Core 2.0 (NETStandard2.0).

You can try it out in the previews releases or use the daily code in master branch.

davidsh avatar Jun 21 '17 01:06 davidsh