mirror of
https://github.com/fergalmoran/podnoms.git
synced 2025-12-26 11:17:47 +00:00
Fixed local file passing
This commit is contained in:
@@ -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<IAudioUploadProcessService>(service => service.UploadAudio(entry.Id));
|
||||
BackgroundJob.Enqueue<IAudioUploadProcessService>(service => service.UploadAudio(entry.Id, localFile));
|
||||
return new OkObjectResult(_mapper.Map<PodcastEntry, PodcastEntryViewModel>(entry));
|
||||
}
|
||||
return NotFound();
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace PodNoms.Api.Controllers
|
||||
{
|
||||
var infoJobId = BackgroundJob.Enqueue<IUrlProcessService>(service => service.GetInformation(entry.Id));
|
||||
var extract = BackgroundJob.ContinueWith<IUrlProcessService>(infoJobId, service => service.DownloadAudio(entry.Id));
|
||||
var upload = BackgroundJob.ContinueWith<IAudioUploadProcessService>(extract, service => service.UploadAudio(entry.Id));
|
||||
var upload = BackgroundJob.ContinueWith<IAudioUploadProcessService>(extract, service => service.UploadAudio(entry.Id, entry.AudioUrl));
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace PodNoms.Api.Services.Processor
|
||||
this._fileUploader = fileUploader;
|
||||
this._audioStorageSettings = audioStorageSettings.Value;
|
||||
}
|
||||
public async Task<bool> UploadAudio(int entryId)
|
||||
public async Task<bool> 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)
|
||||
|
||||
@@ -4,6 +4,6 @@ namespace PodNoms.Api.Services.Processor
|
||||
{
|
||||
public interface IAudioUploadProcessService
|
||||
{
|
||||
Task<bool> UploadAudio(int entryId);
|
||||
Task<bool> UploadAudio(int entryId, string localFile);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user