0

I have a filepath I am getting through calling an API. I am sending this filepath to the API again to merge all files into one single file.

For reading a file in the API I am using HttpContext.Current.Request.Files in my application, but this is not giving a count. Is there any possible way to do this? Reading a file through filePath without going through upload file functionality.

I am calling this API

return $ajax.post('/api/convert/applicationtemp/CollateDoc/' + appID + '/' + DocName + '/' + Password + '/' + pageType, filepath);

This is the ASP.Net code:

[Route("CollateDoc/{applicationID}/{pdfFileName}/{pdfPassword}/{pageSize}")]
public bool CollateDocumentAndSaveToNAS(string applicationID, string pdfFileName, string pdfPassword, string pageSize, string [] filepath)
{
  var httpRequest = HttpContext.Current.Request;
  var http = httpRequest.Files;
  var path = Path.Combine(HttpContext.Current.Server.MapPath(filepath) + documentspath, applicationID.ToString());
  string prefix = DateTime.UtcNow.ToString("yyyy-MM-dd-hh-mm-ss");
  var isCollated = CollateDocInPDF.CollateAllDocumentAndConvertToPDF(httpRequest,path, prefix, pdfFileName, pdfPassword, pageSize);
  return isCollated;
}

I am not getting any file count here after hitting the API.

Dylan
  • 71
  • 5
  • is this helping you? https://stackoverflow.com/a/15549971/7262120 – Arvind Maurya Oct 09 '19 at 11:50
  • You shouldn't use HttpContext for getting the files in ASP.NET Web API. Take a look at this example written by Microsoft (http://code.msdn.microsoft.com/ASPNET-Web-API-File-Upload-a8c0fb0d/sourcecode?fileId=67087&pathId=565875642). – Arvind Maurya Oct 09 '19 at 11:51

0 Answers0