Remotely/Remotely_Server/API/CoreVersionController.cs
2021-07-29 07:53:44 -07:00

33 lines
885 B
C#

using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
namespace Remotely_Server.API
{
[Route("api/[controller]")]
public class CoreVersionController : Controller
{
public CoreVersionController(IHostingEnvironment hostingEnv)
{
this.HostingEnv = hostingEnv;
}
public IHostingEnvironment HostingEnv { get; }
// GET: api/<controller>
[HttpGet("{platform}")]
public string Get(string platform)
{
var filePath = Path.Combine(HostingEnv.WebRootPath, "Downloads", "CurrentAgentVersion.txt");
if (!System.IO.File.Exists(filePath))
{
return "0.0.0.0";
}
return System.IO.File.ReadAllText(filePath).Trim();
}
}
}