How to upload folder and its contents to rest web service c#? - c#

I dont find any tutorials on how to upload folder and its contents to rest web service using c#? The content-type is application/json. Is there any way to do this?

Related

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?

C#.Net get website folder from web api

I have a website and web api which made on .net platform.
Web api has a ImageUpload(...) method. I get images as base64 encoded string and saving after turning into byte[].
Here is the story:
Web api's root folder located at: domain.com/API and website's: domain.com/httpdocs.
I hold uploaded images in httpdocs/files/images folder. So it's different folder than web api's. Therefore I am not able to save images in httpdocs/files/images folder. Because web api's context's top folder is httpdocs/API. I can't access httpdocs/ folder.
Any idea how to achieve that?
Try using Server.MapPath to get the server side path.

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.

Streaming a file from WCF service

I am trying to figure out how to stream a file (typically a PDF) from a web service that is front ended by a typical web site. The PDFs do not physically exist, but are created on the fly by a report generator (think Crystal, Telerik Reporting, etc.)
I can do this today directly from the web site by doing a Response.Clear() followed by setting the ContentType and adding the appropriate Content-Disposition header finally followed up by a Response.BinaryWrite(...).
But, a WCF service (IIS hosted in this case), does not have a Response object. I have tried passing in the Response object from my web page as a parameter, but I can't even start the WCF Service because HttpResponse cannot be serialized.
Am I barking up the wrong tree? Is there a better way of looking at this? We wanted it in a common web service because more of our web sites are needing to do this and we don't want to maintain multiple copies of the code to do it.
You can send your file as byte[] array.
Or you can send this file as a Stream parameter (using Streamed mode)

Categories