|
|
|
|
|
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
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
[HttpGet("~" + Constants.ApiVersionPrefix + ApiConfig.ContentBase + "/{id}/{version}/{idf}.{versionFromName}."
|
|
|
|
|
|
+ Constants.PacketFileExtension)]
|
|
|
|
|
|
public IActionResult GetPackage(
|
|
|
|
|
|
[FromRoute][SafeName][Required] string id,
|
|
|
|
|
|
[FromRoute][SafeName][Required] string version,
|
|
|
|
|
|
[FromRoute] string idf, [FromRoute] string versionFromName)
|
|
|
|
|
|
{
|
|
|
|
|
|
var pkgPath = Path.Combine(isndSettings.PackagesRootDir,
|
|
|
|
|
|
id, version, $"{id}-{version}." + Constants.PacketFileExtension
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
FileInfo pkgFileInfo = new FileInfo(pkgPath);
|
|
|
|
|
|
|
|
|
|
|
|
if (!pkgFileInfo.Exists)
|
|
|
|
|
|
{
|
|
|
|
|
|
return BadRequest("Package does´nt exist in the file system.");
|
|
|
|
|
|
}
|
|
|
|
|
|
return File(pkgFileInfo.OpenRead(), "application/zip; charset=binary");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Web get spec
|
|
|
|
|
|
[HttpGet("~" + Constants.ApiVersionPrefix + ApiConfig.ContentBase + "/{id}/{lower}/{idf}-{lowerFromName}."
|
|
|
|
|
|
+ Constants.SpecFileExtension)]
|
|
|
|
|
|
public IActionResult GetNuspec(
|
|
|
|
|
|
[FromRoute][SafeName][Required] string id,
|
|
|
|
|
|
[FromRoute][SafeName][Required] string lower,
|
|
|
|
|
|
[FromRoute][SafeName][Required] string idf,
|
|
|
|
|
|
[FromRoute][SafeName][Required] string lowerFromName)
|
|
|
|
|
|
{
|
|
|
|
|
|
var pkgPath = Path.Combine(isndSettings.PackagesRootDir,
|
|
|
|
|
|
id, lower, $"{id}." + Constants.SpecFileExtension);
|
|
|
|
|
|
|
|
|
|
|
|
FileInfo pkgFileInfo = new FileInfo(pkgPath);
|
|
|
|
|
|
if (!pkgFileInfo.Exists)
|
|
|
|
|
|
{
|
|
|
|
|
|
return BadRequest("Package info does´nt exist in the file system.");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return File(pkgFileInfo.OpenRead(), "text/xml; charset=utf-8");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|