How to download file into webserver using only angular frontend? - c#

I have a frontend website made using Angular that accepts an uploaded file. I want to be able to save this file into the web server the website is being hosted on. I would prefer to only use Angular to do this, but I can also accept if there is a way to do it in ASP.Net Web API backend.

You can download the webserver file using angular.
Try the below example...
downloadFile() {
window.open("http://www.africau.edu/images/default/sample.pdf") //your URL
}

Related

HttpListener vs HttpSelfHostServer WebApi

Writing an windows service using the .net framework (not dotnetcore) with c# that needs a web interface to manage it. No IIS or anything else installed other than the app to serve html files for the web interface - so need a webserver to serve static html files.
The static html file that will be served will call web api methods via javascript to query data and manage the internals of the service.
Already using self hosted web api with HttpSelfHostServer to write methods that can be queried via javascript using ApiController.
To serve the static html file I could do the following:
Use HttpListener to serve the static html file
Write a method in a ApiController that returns FileContent using HttpSelfHostServer and create a "index.html" route
Since they are just static files I could just HttpSelfHostServer and have a webapi method return the contents of the html file.
Not sure if there is a benefit of one over the other in this case. Any thoughts?

Get the download link of file on remote server as a property in json response web api

I have uploaded files using web app made with asp.net web mvc, using Server.MapPath() and all that. Now its on remote server.
All i want its http download url so that i can send this link via json and users on mobile can download that file?
Windows Server 2008 and IIS 7.
Link to Image of Json Response
FilePath property should have file download link but right now its giving me physical path of file where it is located on hard drive. Any thoughts on how to get download url?

"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