简体   繁体   中英

Passing a file upload to a web service

I have the following architecture:

Web-Application <-> Web-Service <-> Cloud

The web-application provides a html page for uploading a file which should be placed in the cloud. It is, by design, not possible to upload directly to the cloud (this is really no option here).

What I could do is, to upload it to the web-application and save the file to disk, then upload it to the web-service, save to disk and finally upload it to the cloud. But because the file could be large (4GB+) it would be nice just to pass the stream from the web-application to the web-service and the web-service passes it to the cloud, so it does not get saved to file anywhere instead of the cloud.

Is this possible with C#, .NET 4, ASP.NET and MVC 4?

It was really easy.

Within my Web-Application Action I just created a new HttpWebRequest, copied the file's inputstream to the HttpWebRequest and sent it to the Web-Service. Same thing from Web-Service to the Cloud. So no storage to disk is needed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM