简体   繁体   中英

Using ASP.NET WebAPI v2, how do I POST PDF data in a WebAPI method?

The idea is that there will be an external entity (SharePoint) that will call my WebAPI and pass in a PDF file as well as some extra, metadata information about that PDF file. I'm stuck on how to construct the signature of the Web API method. Here's what I have so far:

public class IssueController : ApiController
{
    private TestEntities db = new TestEntities(HelperClasses.ConnectionStringHelper.GetConnectionString());

    [HttpPost]
    public HttpResponseMessage SavePdf(Article a)
    {
        // save the PDF to a file share & metadata to the SQL database
    }
}

My inclination would be to do something like:

public class IssueController : ApiController
{
    private TestEntities db = new TestEntities(HelperClasses.ConnectionStringHelper.GetConnectionString());

    [HttpPost]
    public HttpResponseMessage SavePdf(Article a, HttpPostedFileBase file)
    {
        // save the PDF to a file share & metadata to the SQL database
    }
}

But, I'm not sure with WebAPI how to exactly do this.

QUESTION : How would I define a WebAPI method capable of accepting PDF data & some extra metadata as a POST request from an external entity?

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