diff --git a/RMuseum/Controllers/AudioNarrationController.cs b/RMuseum/Controllers/AudioNarrationController.cs
index 8b154ce8..d0ddfc72 100644
--- a/RMuseum/Controllers/AudioNarrationController.cs
+++ b/RMuseum/Controllers/AudioNarrationController.cs
@@ -12,6 +12,7 @@ using RSecurityBackend.Models.Generic;
using RSecurityBackend.Services;
using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
@@ -69,6 +70,78 @@ namespace RMuseum.Controllers
return Ok(res.Result.Items);
}
+ ///
+ /// get the corresponding mp3 file for the narration
+ ///
+ ///
+ /// it could be protected (Authorized), but I guess I would have problems with available client components support,
+ /// so I preferred it to be anonymous, as it does not harm anybody I guess
+ ///
+ ///
+ ///
+ [HttpGet("file/{id}.mp3")]
+ [AllowAnonymous]
+ [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(FileStreamResult))]
+ [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
+ public async Task GetMp3File(int id)
+ {
+ RServiceResult narration =
+ await _audioService.Get(id);
+
+ if (!string.IsNullOrEmpty(narration.ExceptionString))
+ return BadRequest(narration.ExceptionString);
+
+ if (narration.Result == null)
+ return NotFound();
+
+ Response.GetTypedHeaders().LastModified = narration.Result.UploadDate;//TODO: Add a FileLastUpdated field to narrations to indicate the last time the mp3/xml files have been updated
+
+ var requestHeaders = Request.GetTypedHeaders();
+ if (requestHeaders.IfModifiedSince.HasValue &&
+ requestHeaders.IfModifiedSince.Value >= narration.Result.UploadDate)
+ {
+ return StatusCode(StatusCodes.Status304NotModified);
+ }
+
+ return new FileStreamResult(new FileStream(narration.Result.LocalMp3FilePath, FileMode.Open, FileAccess.Read), "audio/mpeg");
+ }
+
+ ///
+ /// get the corresponding xml file for the narration
+ ///
+ ///
+ /// it could be protected (Authorized), but I guess I would have problems with available client components support,
+ /// so I preferred it to be anonymous, as it does not harm anybody I guess
+ ///
+ ///
+ ///
+ [HttpGet("file/{id}.xml")]
+ [AllowAnonymous]
+ [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(FileStreamResult))]
+ [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
+ public async Task GetXMLFile(int id)
+ {
+ RServiceResult narration =
+ await _audioService.Get(id);
+
+ if (!string.IsNullOrEmpty(narration.ExceptionString))
+ return BadRequest(narration.ExceptionString);
+
+ if (narration.Result == null)
+ return NotFound();
+
+ Response.GetTypedHeaders().LastModified = narration.Result.UploadDate;//TODO: Add a FileLastUpdated field to narrations to indicate the last time the mp3/xml files have been updated
+
+ var requestHeaders = Request.GetTypedHeaders();
+ if (requestHeaders.IfModifiedSince.HasValue &&
+ requestHeaders.IfModifiedSince.Value >= narration.Result.UploadDate)
+ {
+ return StatusCode(StatusCodes.Status304NotModified);
+ }
+
+ return new FileStreamResult(new FileStream(narration.Result.LocalXmlFilePath, FileMode.Open, FileAccess.Read), "text/xml");
+ }
+
///
/// updates narration metadata
///
diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml
index 2649deaf..144f8a89 100644
--- a/RMuseum/RMuseum.xml
+++ b/RMuseum/RMuseum.xml
@@ -635,6 +635,28 @@
default: -1, unfiltered
+
+
+ get the corresponding mp3 file for the narration
+
+
+ it could be protected (Authorized), but I guess I would have problems with available client components support,
+ so I preferred it to be anonymous, as it does not harm anybody I guess
+
+
+
+
+
+
+ get the corresponding xml file for the narration
+
+
+ it could be protected (Authorized), but I guess I would have problems with available client components support,
+ so I preferred it to be anonymous, as it does not harm anybody I guess
+
+
+
+
updates narration metadata