Passing a file upload to a web service - c#

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.

Related

Which server side app should I pick for file transfare scenario

I created some chrome extension that detects a file download event and cancel the download, and gets the download link. Sends the link to myserver.
I want to create a server that recive link to download, download the file, do some manipulation on the file and sends the file back to client.
All the time I developed client side apps (Mainly with c#), and I don't know what to choose for the server side, WCF App or Web API (or something else). the server can be inside the organisation or remote.
What do you think should I pick? any suggestions?
It seems that creating Restful-style services may be more appropriate for this scenario.
You know, both WCF and Asp.net WebAPI can create Restful-style services. WCF could take advantage of the Webhttpbinding to create it.
As for handling file uploads and downloads, I don't think there is any difference between the two techniques. Perhaps the services created by Asp.net WebAPI are a little more mature, such as the ability to deal with form-data stream (multipart/form-data) directly. While WCF service could not directly process the form-data stream.
Here is an example of an upload and download in Asp.net WebAPI.
https://learn.microsoft.com/en-us/aspnet/web-api/overview/advanced/sending-html-form-data-part-2
How to return a file (FileContentResult) in ASP.NET WebAPI
Feel free to let me know if there is anything I can help with.

Where do I store media in an Azure Web App with C# ASP.NET

I am creating a C# ASP.NET app (using Visual Studio), which I'm hosting on Microsoft Azure. Currently, I have a folder in the solution named "Content", in which I store some media. For example, there a logo that is placed on the website.
The purpose of the web app is to generate a document that a user can download after entering some data. To generate this document, I also need to use some media (mainly images). There can be quite a lot of such images!
Where should I store these images? I currently have them in this "Content" folder as well (in seperate sub folders for each user), but I noticed on Azure there is also a tab called "Storage". I have tried to use this service for a bit, but I don't really understand its purpose. Would it be advisable to use this for storing the media, and then retrieving them with the web app when necessary, or should I leave them on the web app server? What is considered Good Practice?
Thanks in advance for any help
As a starting point, using Blob storage (see Azure Storage Documentation) would be significantly better than file storage on a single webserver - its cheaper and more scalable (pricing tiers for Application server storage will be expensive, you'd have have to duplicate files or have a multi-server directory in a load-balanced environment). The basic design is the application will use an SDK to retrieve the bits and then stream it back to the web browser or other client.
If you anticipate many users downloading the same file, and network performance matters, consider using a Content Delivery Network
You should store it in an Azure Storage Account and reference it using the SDK, after generating the document, you can use Shared Access Signature to give the user access and you can limit the access to read or write for a specific time.
If you will generate videos then you can serve it through Azure Media Services

"Restreaming" upload files to web api

I am trying to upload a file from a client to a MVC application, and then have the MVC application pass the upload file to a web api.
So far I overrode the IHostBufferPolicySelector to stream any incoming HTTP requests that are greater than a given size. So any large file uploads made to MVC is being received as a stream.
I thought of two solutions to this problem, but open to any suggestions.
Have MVC temporarily store the file, then send that file over to the web api
Somehow pass the stream of the file that is coming into MVC, over to the web api
Is there a way to achieve option 2? Can I pass an incoming stream to another web service?

How to create server on ASP.NET Web API?

I would like to create a web server application using ASP.Net WebApi 2. The application must parse a HTML page and upload clear data to Azure blob storage.
I've never created Web applications and I don't know how is right worked. Please show me how it is worked and what tehnology to use.
I would like to use ASP.Net WebApi 2, so that I can create an API that parses and uploads data to Azure blob storage.
Please check out many tutorials there are on the internet.
http://azure.microsoft.com/en-us/documentation/articles/web-sites-dotnet-get-started/
http://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-how-to-use-blobs/

Upload a video using asp.net MVC WebService

I want to upload a video file using asp.net mvc . I am sending the file as postbody. How can this be retrieved later from the server using webservice. I have seen this example . Also this question helped me to understand it more. But I m not sure how to fetch post body.
But no sure how this works. How to do his properly in .net c#
In order for the file to be available later, you need to save it somewhere during the upload - either to a database or a folder on the server. Then, your web service needs to know how to retrieve it from that location.

Categories