Example #1
0
        public IActionResult UploadFile([FromForm(Name = "files")] List <IFormFile> files, [FromForm(Name = "albumTitle")] string albumTitle, [FromForm(Name = "albumOwner")] string owner)
        {
            try
            {
                string blobName = $"{owner}-{albumTitle}";
                var    location = fileService.SaveFile(files, albumTitle);
                fileService.UploadVideoToBlobStorage(location, blobName, owner, albumTitle).Wait();
                fileService.AddJobToMQ($"{blobName} {albumTitle} {owner}");
                fileService.DeleteFileAndDirectory(location);


                return(Ok(new { files.Count, Size = FileService.SizeConverter(files.Sum(f => f.Length)) }));
            }
            catch (BrokerUnreachableException e)
            {
                return(BadRequest($"No service available, try again later"));
            }
            catch (Exception exception)
            {
                return(BadRequest($"Error: {exception.Message} {albumTitle}:{owner}  {files}"));
            }
        }