Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASMX file upload

Is there a way to upload a file from local filesystem to a folder in a server using ASMX web services(no WCF, don't ask why:)?

UPD

P.S.file size can be 2-10 GB

like image 262
2xMax Avatar asked Jan 25 '11 22:01

2xMax


1 Answers

Sure:

[WebMethod]
public void Upload(byte[] contents, string filename)
{
    var appData = Server.MapPath("~/App_Data");
    var file = Path.Combine(appData, Path.GetFileName(filename));
    File.WriteAllBytes(file, contents);
}

then expose the service, generate a client proxy from the WSDL, invoke, standard stuff.

--

UPDATE:

I see your update now about handling large files. The MTOM protocol with streaming which is built into WCF is optimized for handling such scenarios.

like image 143
Darin Dimitrov Avatar answered Sep 23 '22 17:09

Darin Dimitrov