Support temporary links for local file system provider (#848)

* wip

* Support temporary links for local file system provider

* pass base url to file services

* fix test

* do not crash on errors with local filesystem

* remove console

* fix paranthesis
This commit is contained in:
Andrew Camilleri
2019-05-24 06:44:23 +00:00
committed by Nicolas Dorier
parent 25b08b21fa
commit d86cc9192e
11 changed files with 214 additions and 72 deletions

View File

@@ -1,23 +1,28 @@
using System;
using System.Threading.Tasks;
using BTCPayServer.Configuration;
using BTCPayServer.Storage.Services;
using BTCPayServer.Storage.Services.Providers.FileSystemStorage;
using Microsoft.AspNetCore.Mvc;
namespace BTCPayServer.Storage
{
[Route("Storage")]
public class StorageController
public class StorageController : Controller
{
private readonly FileService _FileService;
private string _dir;
public StorageController(FileService fileService)
public StorageController(FileService fileService, BTCPayServerOptions serverOptions)
{
_FileService = fileService;
_dir =FileSystemFileProviderService.GetTempStorageDir(serverOptions);
}
[HttpGet("{fileId}")]
public async Task<IActionResult> GetFile(string fileId)
{
var url = await _FileService.GetFileUrl(fileId);
var url = await _FileService.GetFileUrl(Request.GetAbsoluteRootUri(), fileId);
return new RedirectResult(url);
}
}