diff --git a/server/Controllers/AudioUploadController.cs b/server/Controllers/AudioUploadController.cs index 2707169..45299e5 100644 --- a/server/Controllers/AudioUploadController.cs +++ b/server/Controllers/AudioUploadController.cs @@ -72,11 +72,11 @@ namespace PodNoms.Api.Controllers Podcast = podcast }; - entry.AudioUrl = await CachedFormFileStorage.CacheItem(file); + var localFile = await CachedFormFileStorage.CacheItem(file); await _entryRepository.AddOrUpdateAsync(entry); await _unitOfWork.CompleteAsync(); - BackgroundJob.Enqueue(service => service.UploadAudio(entry.Id)); + BackgroundJob.Enqueue(service => service.UploadAudio(entry.Id, localFile)); return new OkObjectResult(_mapper.Map(entry)); } return NotFound(); diff --git a/server/Controllers/EntryController.cs b/server/Controllers/EntryController.cs index 130029d..aa91bd4 100644 --- a/server/Controllers/EntryController.cs +++ b/server/Controllers/EntryController.cs @@ -48,7 +48,7 @@ namespace PodNoms.Api.Controllers { var infoJobId = BackgroundJob.Enqueue(service => service.GetInformation(entry.Id)); var extract = BackgroundJob.ContinueWith(infoJobId, service => service.DownloadAudio(entry.Id)); - var upload = BackgroundJob.ContinueWith(extract, service => service.UploadAudio(entry.Id)); + var upload = BackgroundJob.ContinueWith(extract, service => service.UploadAudio(entry.Id, entry.AudioUrl)); } catch (InvalidOperationException ex) { diff --git a/server/Services/Processor/AudioUploadProcessService.cs b/server/Services/Processor/AudioUploadProcessService.cs index f46b494..fee0890 100644 --- a/server/Services/Processor/AudioUploadProcessService.cs +++ b/server/Services/Processor/AudioUploadProcessService.cs @@ -30,7 +30,7 @@ namespace PodNoms.Api.Services.Processor this._fileUploader = fileUploader; this._audioStorageSettings = audioStorageSettings.Value; } - public async Task UploadAudio(int entryId) + public async Task UploadAudio(int entryId, string localFile) { var entry = await _repository.GetAsync(entryId); if (entry == null) @@ -42,10 +42,10 @@ namespace PodNoms.Api.Services.Processor await _unitOfWork.CompleteAsync(); try { - if (File.Exists(entry.AudioUrl)) + if (File.Exists(localFile)) { - var fileName = new FileInfo(entry.AudioUrl).Name; - await _fileUploader.UploadFile(entry.AudioUrl, _audioStorageSettings.ContainerName, fileName, + var fileName = new FileInfo(localFile).Name; + await _fileUploader.UploadFile(localFile, _audioStorageSettings.ContainerName, fileName, async (p, t) => { if (p % 1 == 0) diff --git a/server/Services/Processor/IAudioUploadProcessService.cs b/server/Services/Processor/IAudioUploadProcessService.cs index 5d9a95d..b68d909 100644 --- a/server/Services/Processor/IAudioUploadProcessService.cs +++ b/server/Services/Processor/IAudioUploadProcessService.cs @@ -4,6 +4,6 @@ namespace PodNoms.Api.Services.Processor { public interface IAudioUploadProcessService { - Task UploadAudio(int entryId); + Task UploadAudio(int entryId, string localFile); } } \ No newline at end of file