Quantcast
Channel: Web API
Viewing all articles
Browse latest Browse all 4850

API Method to accept different file types (for upload)

$
0
0

I've been using Web Api in it's most basic form for a while and got to step out of the scope of how I used to do things.

Need to create a method that will take in a file that need to be processed.

This file might be an Xml file, flat file, excel document, etc (for now it's only an XML file...got to get that working)

Since I must do a "test" on the data to decide if this is an xml file, or this or that, etc I'm not sure what my signature should look like.

I got this now (hoping code describe what I'm trying to get sorted out):  

        public HttpResponseMessage UploadDocument(HttpRequestMessage request)
        {
            // what will be returned eventually
            var result = new HttpResponseMessage();     
            // use factory to decide which "handler" will process the posted document (xml, flat, excel, etc)
            IImportHandler handler = ImportFactory.GetHandler(request.Content);

            bool valid = handler.ValidateData(request.Content);

So in a nutshell, I'm asking what should the input be and how to determine if it's an xml document or not?


Viewing all articles
Browse latest Browse all 4850

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>