Fixed local file passing

This commit is contained in:
Fergal Moran
2017-11-12 20:56:43 +00:00
parent dd4007af26
commit de3ef13e1c
4 changed files with 8 additions and 8 deletions

View File

@@ -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();

View File

@@ -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)
{

View File

@@ -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)

View File

@@ -4,6 +4,6 @@ namespace PodNoms.Api.Services.Processor
{
public interface IAudioUploadProcessService
{
Task<bool> UploadAudio(int entryId);
Task<bool> UploadAudio(int entryId, string localFile);
}
}