|
@@ -1,3 +1,6 @@
|
|
|
|
|
+using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
+using RunnersMeet.Server.Domain;
|
|
|
|
|
+
|
|
|
namespace RunnersMeet.Server.Persistence;
|
|
namespace RunnersMeet.Server.Persistence;
|
|
|
|
|
|
|
|
public class FileStorage : IFileStorage
|
|
public class FileStorage : IFileStorage
|
|
@@ -25,6 +28,17 @@ public class FileStorage : IFileStorage
|
|
|
return File.OpenRead(path);
|
|
return File.OpenRead(path);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public FileStreamResult FileDownload(Track track)
|
|
|
|
|
+ {
|
|
|
|
|
+ var fileName = FileName.FromTrack(track);
|
|
|
|
|
+ var path = Path.Combine(_persistenceOptions.FileStorageRootPath, fileName.GetPath());
|
|
|
|
|
+ var fileStream = File.OpenRead(path);
|
|
|
|
|
+ return new FileStreamResult(fileStream, "application/gpx+xml")
|
|
|
|
|
+ {
|
|
|
|
|
+ FileDownloadName = fileName.DisplayName
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private FileStream CreateFile(FileName name)
|
|
private FileStream CreateFile(FileName name)
|
|
|
{
|
|
{
|
|
|
var path = Path.Combine(_persistenceOptions.FileStorageRootPath, name.GetPath());
|
|
var path = Path.Combine(_persistenceOptions.FileStorageRootPath, name.GetPath());
|