Clients will request the conditional download of a binary file from my Web API app.
The method that responds to this request will probably be something like this:
public HttpResponseMessage GetHHSetupUpdate(double clientVersion)
{
double currentVersion = getCurrentVersion("platypiRUs");
if (clientVersion >= currentVersion)
{
return null;
}
var path = @"C:\Platypi\PlatypiRUs.exe";
var stream = new FileStream(path, FileMode.Open);
HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);
result.Content = new StreamContent(stream);
result.Content.Headers.ContentType =
new MediaTypeHeaderValue("application/octet-stream");
return result;
}
What is unnerving me most at present is the location of the file, though. Should it be stored in the project's App_Data folder, or elsewhere?
If so (stored in App_Data), how is that referenced in code? Would it be like:
var path = @"\App_Data\PlatypiRUs.exe";
...or...???
Server.MapPath(@"~\App_Data\PlatypiRUs.exe")
alternatively, you could also use HostingEnvironment.MapPath
instead.