Narration Upload (basic models / not operational yet)
This commit is contained in:
parent
80ccc62162
commit
0a33f8d8c3
@ -1,9 +1,11 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
using RMuseum.Models.Auth.Memory;
|
||||
using RMuseum.Models.GanjoorAudio;
|
||||
using RMuseum.Models.GanjoorAudio.ViewModels;
|
||||
using RMuseum.Models.UploadSession;
|
||||
using RMuseum.Services;
|
||||
using RSecurityBackend.Models.Generic;
|
||||
using RSecurityBackend.Services;
|
||||
@ -66,6 +68,36 @@ namespace RMuseum.Controllers
|
||||
return Ok(res.Result.Items);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Narration Upload
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Authorize]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(UploadSession))]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
[ProducesResponseType((int)HttpStatusCode.Unauthorized)]
|
||||
[ProducesResponseType((int)HttpStatusCode.Forbidden, Type = typeof(string))]
|
||||
public async Task<IActionResult> UploadNarrations()
|
||||
{
|
||||
try
|
||||
{
|
||||
Guid loggedOnUserId = new Guid(User.Claims.FirstOrDefault(c => c.Type == "UserId").Value);
|
||||
RServiceResult<UploadSession> resSession = await _audioService.InitiateNewUploadSession(loggedOnUserId);
|
||||
if (!string.IsNullOrEmpty(resSession.ExceptionString))
|
||||
return BadRequest(resSession.ExceptionString);
|
||||
foreach(IFormFile file in Request.Form.Files)
|
||||
{
|
||||
|
||||
}
|
||||
return Ok(await _audioService.GetUploadSession(resSession.Result.Id));
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
return BadRequest(exp.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// imports data from ganjoor MySql database
|
||||
|
||||
@ -3,6 +3,7 @@ using Microsoft.Extensions.Configuration;
|
||||
using RMuseum.Models.Artifact;
|
||||
using RMuseum.Models.Bookmark;
|
||||
using RMuseum.Models.GanjoorAudio;
|
||||
using RMuseum.Models.UploadSession;
|
||||
using RMuseum.Models.GanjoorIntegration;
|
||||
using RMuseum.Models.ImportJob;
|
||||
using RMuseum.Models.Note;
|
||||
@ -132,5 +133,10 @@ namespace RMuseum.DbContext
|
||||
/// </summary>
|
||||
public DbSet<PoemNarration> AudioFiles { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Upload Sessions
|
||||
/// </summary>
|
||||
public DbSet<UploadSession> UploadSessions { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
69
RMuseum/Models/UploadSession/UploadSession.cs
Normal file
69
RMuseum/Models/UploadSession/UploadSession.cs
Normal file
@ -0,0 +1,69 @@
|
||||
using RSecurityBackend.Models.Auth.Db;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace RMuseum.Models.UploadSession
|
||||
{
|
||||
/// <summary>
|
||||
/// Upload Session
|
||||
/// </summary>
|
||||
public class UploadSession
|
||||
{
|
||||
/// <summary>
|
||||
/// Id
|
||||
/// </summary>
|
||||
public Guid Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Session Type
|
||||
/// </summary>
|
||||
public UploadSessionType SessionType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// User
|
||||
/// </summary>
|
||||
public RAppUser User { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// User Id
|
||||
/// </summary>
|
||||
public Guid UseId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Upload Start Time
|
||||
/// </summary>
|
||||
public DateTime UploadStartTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Upload End Time
|
||||
/// </summary>
|
||||
public DateTime UploadEndTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Process Start Time
|
||||
/// </summary>
|
||||
public DateTime ProcessStartTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Process End Time
|
||||
/// </summary>
|
||||
public DateTime ProcessEndTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Process Progress
|
||||
/// </summary>
|
||||
public int ProcessProgress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Status
|
||||
/// </summary>
|
||||
public UploadSessionProcessStatus Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Uploaded Files
|
||||
/// </summary>
|
||||
public ICollection<UploadSessionFile> UploadedFiles { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
48
RMuseum/Models/UploadSession/UploadSessionFile.cs
Normal file
48
RMuseum/Models/UploadSession/UploadSessionFile.cs
Normal file
@ -0,0 +1,48 @@
|
||||
using System;
|
||||
|
||||
|
||||
namespace RMuseum.Models.UploadSession
|
||||
{
|
||||
/// <summary>
|
||||
/// Upload Session File
|
||||
/// </summary>
|
||||
public class UploadSessionFile
|
||||
{
|
||||
/// <summary>
|
||||
/// Id
|
||||
/// </summary>
|
||||
public Guid Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ContentDisposition
|
||||
/// </summary>
|
||||
public string ContentDisposition { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ContentType
|
||||
/// </summary>
|
||||
public string ContentType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// FileName
|
||||
/// </summary>
|
||||
public string FileName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Length
|
||||
/// </summary>
|
||||
public long Length { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Name
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// File Path
|
||||
/// </summary>
|
||||
public string FilePath { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
21
RMuseum/Models/UploadSession/UploadSessionProcessStatus.cs
Normal file
21
RMuseum/Models/UploadSession/UploadSessionProcessStatus.cs
Normal file
@ -0,0 +1,21 @@
|
||||
namespace RMuseum.Models.UploadSession
|
||||
{
|
||||
/// <summary>
|
||||
/// Upload Session Process Status
|
||||
/// </summary>
|
||||
public enum UploadSessionProcessStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// Not Started
|
||||
/// </summary>
|
||||
NotStarted = 0,
|
||||
/// <summary>
|
||||
/// Started
|
||||
/// </summary>
|
||||
Started = 1,
|
||||
/// <summary>
|
||||
/// Finished
|
||||
/// </summary>
|
||||
Finished = 2
|
||||
}
|
||||
}
|
||||
20
RMuseum/Models/UploadSession/UploadSessionType.cs
Normal file
20
RMuseum/Models/UploadSession/UploadSessionType.cs
Normal file
@ -0,0 +1,20 @@
|
||||
|
||||
namespace RMuseum.Models.UploadSession
|
||||
{
|
||||
/// <summary>
|
||||
/// Upload Session Types
|
||||
/// </summary>
|
||||
public enum UploadSessionType
|
||||
{
|
||||
/// <summary>
|
||||
/// Generic
|
||||
/// </summary>
|
||||
Generic = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Audio
|
||||
/// </summary>
|
||||
Audio = 1
|
||||
|
||||
}
|
||||
}
|
||||
@ -629,6 +629,12 @@
|
||||
<param name="status">default: -1, unfiltered</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.AudioNarrationController.UploadNarrations">
|
||||
<summary>
|
||||
Narration Upload
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.AudioNarrationController.MysqlonetimeImport">
|
||||
<summary>
|
||||
imports data from ganjoor MySql database
|
||||
@ -814,6 +820,11 @@
|
||||
Ganjoor Audio Files
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.DbContext.RMuseumDbContext.UploadSessions">
|
||||
<summary>
|
||||
Upload Sessions
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:RMuseum.Models.Artifact.PublishStatus">
|
||||
<summary>
|
||||
Items or pictures status
|
||||
@ -2698,6 +2709,141 @@
|
||||
Text
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:RMuseum.Models.UploadSession.UploadSession">
|
||||
<summary>
|
||||
Upload Session
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.UploadSession.UploadSession.Id">
|
||||
<summary>
|
||||
Id
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.UploadSession.UploadSession.SessionType">
|
||||
<summary>
|
||||
Session Type
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.UploadSession.UploadSession.User">
|
||||
<summary>
|
||||
User
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.UploadSession.UploadSession.UseId">
|
||||
<summary>
|
||||
User Id
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.UploadSession.UploadSession.UploadStartTime">
|
||||
<summary>
|
||||
Upload Start Time
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.UploadSession.UploadSession.UploadEndTime">
|
||||
<summary>
|
||||
Upload End Time
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.UploadSession.UploadSession.ProcessStartTime">
|
||||
<summary>
|
||||
Process Start Time
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.UploadSession.UploadSession.ProcessEndTime">
|
||||
<summary>
|
||||
Process End Time
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.UploadSession.UploadSession.ProcessProgress">
|
||||
<summary>
|
||||
Process Progress
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.UploadSession.UploadSession.Status">
|
||||
<summary>
|
||||
Status
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.UploadSession.UploadSession.UploadedFiles">
|
||||
<summary>
|
||||
Uploaded Files
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:RMuseum.Models.UploadSession.UploadSessionFile">
|
||||
<summary>
|
||||
Upload Session File
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.UploadSession.UploadSessionFile.Id">
|
||||
<summary>
|
||||
Id
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.UploadSession.UploadSessionFile.ContentDisposition">
|
||||
<summary>
|
||||
ContentDisposition
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.UploadSession.UploadSessionFile.ContentType">
|
||||
<summary>
|
||||
ContentType
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.UploadSession.UploadSessionFile.FileName">
|
||||
<summary>
|
||||
FileName
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.UploadSession.UploadSessionFile.Length">
|
||||
<summary>
|
||||
Length
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.UploadSession.UploadSessionFile.Name">
|
||||
<summary>
|
||||
Name
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.UploadSession.UploadSessionFile.FilePath">
|
||||
<summary>
|
||||
File Path
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:RMuseum.Models.UploadSession.UploadSessionProcessStatus">
|
||||
<summary>
|
||||
Upload Session Process Status
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:RMuseum.Models.UploadSession.UploadSessionProcessStatus.NotStarted">
|
||||
<summary>
|
||||
Not Started
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:RMuseum.Models.UploadSession.UploadSessionProcessStatus.Started">
|
||||
<summary>
|
||||
Started
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:RMuseum.Models.UploadSession.UploadSessionProcessStatus.Finished">
|
||||
<summary>
|
||||
Finished
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:RMuseum.Models.UploadSession.UploadSessionType">
|
||||
<summary>
|
||||
Upload Session Types
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:RMuseum.Models.UploadSession.UploadSessionType.Generic">
|
||||
<summary>
|
||||
Generic
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:RMuseum.Models.UploadSession.UploadSessionType.Audio">
|
||||
<summary>
|
||||
Audio
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:RMuseum.Services.IArtifactService">
|
||||
<summary>
|
||||
Artifact Item Service
|
||||
@ -3234,6 +3380,20 @@
|
||||
<param name="OwnrRAppUserId">User Id which becomes owner of imported data</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IAudioNarrationService.InitiateNewUploadSession(System.Guid)">
|
||||
<summary>
|
||||
Initiate New Upload Session for audio
|
||||
</summary>
|
||||
<param name="userId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IAudioNarrationService.GetUploadSession(System.Guid)">
|
||||
<summary>
|
||||
Get Upload Session (including files)
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:RMuseum.Services.Implementation.ArtifactService">
|
||||
<summary>
|
||||
IArtifactService implementation
|
||||
@ -3962,6 +4122,20 @@
|
||||
</summary>
|
||||
<param name="OwnrRAppUserId">User Id which becomes owner of imported data</param>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.AudioNarrationService.InitiateNewUploadSession(System.Guid)">
|
||||
<summary>
|
||||
Initiate New Upload Session for audio
|
||||
</summary>
|
||||
<param name="userId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.AudioNarrationService.GetUploadSession(System.Guid)">
|
||||
<summary>
|
||||
Get Upload Session (including files)
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="P:RMuseum.Services.Implementation.AudioNarrationService.Configuration">
|
||||
<summary>
|
||||
Configuration
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using RMuseum.Models.GanjoorAudio;
|
||||
using RMuseum.Models.GanjoorAudio.ViewModels;
|
||||
using RMuseum.Models.UploadSession;
|
||||
using RSecurityBackend.Models.Generic;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
@ -26,5 +27,19 @@ namespace RMuseum.Services
|
||||
/// <param name="OwnrRAppUserId">User Id which becomes owner of imported data</param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<bool>> OneTimeImport(Guid OwnrRAppUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Initiate New Upload Session for audio
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<UploadSession>> InitiateNewUploadSession(Guid userId);
|
||||
|
||||
/// <summary>
|
||||
/// Get Upload Session (including files)
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<UploadSession>> GetUploadSession(Guid id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ using MySql.Data.MySqlClient;
|
||||
using RMuseum.DbContext;
|
||||
using RMuseum.Models.GanjoorAudio;
|
||||
using RMuseum.Models.GanjoorAudio.ViewModels;
|
||||
using RMuseum.Models.UploadSession;
|
||||
using RSecurityBackend.Models.Generic;
|
||||
using RSecurityBackend.Services.Implementation;
|
||||
using System;
|
||||
@ -136,6 +137,56 @@ namespace RMuseum.Services.Implementation
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initiate New Upload Session for audio
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<UploadSession>> InitiateNewUploadSession(Guid userId)
|
||||
{
|
||||
try
|
||||
{
|
||||
UploadSession session = new UploadSession()
|
||||
{
|
||||
SessionType = UploadSessionType.Audio,
|
||||
UseId = userId,
|
||||
UploadStartTime = DateTime.Now,
|
||||
Status = UploadSessionProcessStatus.NotStarted,
|
||||
ProcessProgress = 0
|
||||
};
|
||||
await _context.UploadSessions.AddAsync(session);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return new RServiceResult<UploadSession>(session);
|
||||
|
||||
}
|
||||
catch(Exception exp)
|
||||
{
|
||||
return new RServiceResult<UploadSession>(null, exp.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Upload Session (including files)
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<UploadSession>> GetUploadSession(Guid id)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new RServiceResult<UploadSession>
|
||||
(
|
||||
await _context.UploadSessions.Include(s => s.UploadedFiles).FirstOrDefaultAsync(s => s.Id == id)
|
||||
);
|
||||
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
return new RServiceResult<UploadSession>(null, exp.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Configuration
|
||||
|
||||
@ -251,6 +251,12 @@ namespace RMuseum
|
||||
//audio service
|
||||
services.AddTransient<IAudioNarrationService, AudioNarrationService>();
|
||||
|
||||
//upload limit for IIS
|
||||
services.Configure<IISServerOptions>(options =>
|
||||
{
|
||||
options.MaxRequestBodySize = 52428800; //50MB
|
||||
});
|
||||
|
||||
|
||||
services.AddHostedService<QueuedHostedService>();
|
||||
services.AddSingleton<IBackgroundTaskQueue, BackgroundTaskQueue>();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user