Download ASMX file

Is there a way to upload a file from the local file system to a folder on the server using ASMX web services (without WCF, don’t ask why :)?

UPD

PS file size may be 2-10 GB

+7
source share
4 answers

When developing my free tool for uploading large files to the server, I also use .NET 2.0 and web services.

To make the application more error-resistant for very large files, I decided not to load one large byte[] array, but to do a “chuncked” download instead.

those. To download a 1 MB file, I call the SOAP download function 20 times, each call passes a 50 KB byte[] array and combines it on the server again.

I also count packets, when one crashes, I try to download it again several times.

This makes the download more error tolerant and more responsive in the user interface.

If you're interested, this is a CP tool article .

+2
source

Of course:

 [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 output the service, generate the client proxy from WSDL, call the standard material.

-

UPDATE:

Now I see your update on processing large files. The streaming MTOM protocol, which is built into WCF, is optimized to handle such scenarios.

+9
source

For very large files, the only effective way to submit them to web services is MTOM . And MTOM is only supported in WCF , which you excluded. The only way to do this with the old .asmx web services is with the answer that Dardin Dimitrov gave. And with this solution, you will have to suffer from the cost of a base64 encoded file (33% more bandwidth).

0
source

We had the same requirement, basically downloading the file via HTTP POST using standard client-side FileUpload controls. As a result, we simply added the ASPX page to the ASMX web service project (after just our web project) - this allowed us to load, i.e. http://foo/bar/Upload.aspx when the web service was at http://foo/bar/baz.asmx . This retained functionality in the web service, although it used a separate web page.

This may or may not meet your requirements, the @ Darins approach will also work as a workaround, but for this you will have to make changes on the client side, which was not an option for us.

0
source

All Articles