[英]How do I upload csv file from FTP directly which will be as input in c#?
[英]How do I directly upload the images to FTP from the given image path(Live URL)
我正在执行的任务是,需要使用给定实时路径中的C#编码将图像上传到特定的FTP。
目前,我已经完成了,但是要在FTP上上传图像,我需要往返(在本地下载图像,然后使用代码将其上传到现场)。
我希望解决方案直接将图像上传到ftp,而无需下载。
例如。 从给定路径http://www.globalgear.com.au/products/bladesbook_sml.jpg
我需要这张图片上传。
您好,我想更正我的问题,我想从此URL(globalgear.com.au/productfeed.xml)提取大小图像,然后直接上传到FTP,而无需在本地下载。 –
请提出任何解决方案。
谢谢谢坦
也许这会起作用:
// Get the object used to communicate with the server.
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://www.contoso.com/test.htm");
request.Method = WebRequestMethods.Ftp.UploadFile;
// This example assumes the FTP site uses anonymous logon.
request.Credentials = new NetworkCredential ("anonymous","janeDoe@contoso.com");
// Copy the contents of the file to the request stream.
StreamReader sourceStream = new StreamReader("testfile.txt");
byte [] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
sourceStream.Close();
request.ContentLength = fileContents.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(fileContents, 0, fileContents.Length);
requestStream.Close();
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Console.WriteLine("Upload File Complete, status {0}", response.StatusDescription);
response.Close();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.