using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using System.Text;
using Tallsafe.BigStorage.Core;
using Microsoft.AspNetCore.Authorization;
using System.Reflection;
using System.Net.Http;
using System.Net;
using System.Net.Http.Headers;
namespace TT.Storage.Controllers
{
//[Authorize]
[Route("api/[controller]")]
public class StorageFileController : Controller
{
// GET api/values/5
[Route("GetContent")]
[HttpGet()]
public IActionResult GetContent(string fileInfo)
{
byte[] content = GetFileInfo(fileInfo).FileContent;;
return new FileContentResult(content, "application/octet-stream");
}
// POST api/values
[Route("AddFile")]
[HttpPost]
public StoreFileInfo AddFile([FromBody]byte[] value)
{
if (!Request.ContentLength.HasValue ||
Request.ContentLength <= 0)
{
return null;
}
var contentLength = (int)Request.ContentLength;
byte[] buffer = new byte[contentLength];
Request.Body.Read(buffer, 0, contentLength);
return StorageClassCenter.Store(buffer);
}
}
}