55 lines
1.8 KiB
C#
55 lines
1.8 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using System.IO;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using isnd.Attributes;
|
|
using isnd.Entities;
|
|
using isn.abst;
|
|
|
|
namespace isnd.Controllers
|
|
{
|
|
|
|
public partial class PackagesController
|
|
{
|
|
// Web get the paquet
|
|
[HttpGet(_pkgRootPrefix + ApiConfig.GetPackage + "/{id}/{lower}/{idf}-{lowerf}."
|
|
+ Constants.PaquetFileEstension)]
|
|
public IActionResult GetPackage(
|
|
[FromRoute][SafeName][Required] string id,
|
|
[FromRoute][SafeName][Required] string lower,
|
|
[FromRoute] string idf, [FromRoute] string lowerf)
|
|
{
|
|
var pkgpath = Path.Combine(isndSettings.PackagesRootDir,
|
|
id, lower, $"{id}-{lower}." + Constants.PaquetFileEstension
|
|
);
|
|
|
|
FileInfo pkgfi = new FileInfo(pkgpath);
|
|
|
|
if (!pkgfi.Exists)
|
|
{
|
|
return BadRequest("!pkgfi.Exists");
|
|
}
|
|
return File(pkgfi.OpenRead(), "application/zip; charset=binary");
|
|
}
|
|
|
|
// Web get spec
|
|
[HttpGet(_pkgRootPrefix + Constants.SpecFileEstension + "/{id}/{lower}/{idf}-{lowerf}."
|
|
+ Constants.SpecFileEstension)]
|
|
public IActionResult GetNuspec(
|
|
[FromRoute][SafeName][Required] string id,
|
|
[FromRoute][SafeName][Required] string lower,
|
|
[FromRoute][SafeName][Required] string idf,
|
|
[FromRoute][SafeName][Required] string lowerf)
|
|
{
|
|
var pkgpath = Path.Combine(isndSettings.PackagesRootDir,
|
|
id, lower, $"{id}." + Constants.SpecFileEstension);
|
|
|
|
FileInfo pkgfi = new FileInfo(pkgpath);
|
|
if (!pkgfi.Exists)
|
|
{
|
|
return BadRequest("!pkgfi.Exists");
|
|
}
|
|
|
|
return File(pkgfi.OpenRead(), "text/xml; charset=utf-8");
|
|
}
|
|
}
|
|
} |