diff --git a/RMuseum/Controllers/RecitationController.cs b/RMuseum/Controllers/RecitationController.cs
index d5ead367..db6a7eba 100644
--- a/RMuseum/Controllers/RecitationController.cs
+++ b/RMuseum/Controllers/RecitationController.cs
@@ -187,7 +187,7 @@ namespace RMuseum.Controllers
///
- /// get the corresponding xml file contemnts (xml) for the narration
+ /// get the corresponding xml file contents (xml) for the narration
///
///
/// it could be protected (Authorized), but I guess I would have problems with available client components support,
@@ -223,6 +223,42 @@ namespace RMuseum.Controllers
return Ok(System.IO.File.ReadAllText(narration.Result.LocalXmlFilePath));
}
+ ///
+ /// get the corresponding xml file for the recitation
+ ///
+ ///
+ /// 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");
+ }
+
///
/// Gets Verse Sync Information
///
diff --git a/RMuseum/Models/GanjoorAudio/ViewModels/PublicRecitationViewModel.cs b/RMuseum/Models/GanjoorAudio/ViewModels/PublicRecitationViewModel.cs
index df1693c5..1e37000d 100644
--- a/RMuseum/Models/GanjoorAudio/ViewModels/PublicRecitationViewModel.cs
+++ b/RMuseum/Models/GanjoorAudio/ViewModels/PublicRecitationViewModel.cs
@@ -83,7 +83,7 @@ namespace RMuseum.Models.GanjoorAudio.ViewModels
public string Mp3Url { get; set; }
///
- /// Xml Url
+ /// Xml Text, xml file url is https://ganjgah.ir/api/audio/file/{audio.Id}.xml
///
public string XmlText { get; set; }