public async Task <IActionResult> Upload(ICollection <IFormFile> files)
        {
            bool   isUploaded = false;
            string exs        = "exs:";

            try
            {
                if (files.Count == 0)
                {
                    return(BadRequest("No files received from the upload"));
                }

                if (storageConfig.AccountKey == string.Empty || storageConfig.AccountName == string.Empty)
                {
                    return(BadRequest("sorry, can't retrieve your azure storage details from appsettings.js, make sure that you add azure storage details there"));
                }

                if (storageConfig.ImageContainer == string.Empty)
                {
                    return(BadRequest("Please provide a name for your image container in the azure blob storage"));
                }

                exs += " Finished Initial Validation: Count=" + files.Count + "; " + files.First() + "; ";
                var i = 0;
                foreach (var formFile in files)
                {
                    exs += " Checking File " + i + "; ";
                    if (StorageHelper.IsImage(formFile))
                    {
                        exs += " File is Image: " + (i++) + "; ";
                        if (formFile.Length > 0)
                        {
                            using (Stream stream = formFile.OpenReadStream())
                            {
                                isUploaded = await StorageHelper.UploadFileToStorage(stream, formFile.FileName, storageConfig);
                            }
                        }
                    }
                    else
                    {
                        return(new UnsupportedMediaTypeResult());
                    }
                }

                if (isUploaded)
                {
                    if (storageConfig.ThumbnailContainer != string.Empty)
                    {
                        return(new AcceptedAtActionResult("GetThumbNails", "Images", null, null));
                    }

                    else
                    {
                        return(Ok("image uploaded"));
                    }
                }
                else
                {
                    return(BadRequest("Look like the image couldnt upload to the storage"));
                }
            }
            catch (Exception ex)
            {
                return(BadRequest("Ex: " + exs + " " + ex.Message + " " + ex.StackTrace));
            }
        }
        public async Task <IActionResult> Upload(ICollection <IFormFile> files)
        {
            bool isUploaded = false;

            try
            {
                if (files.Count == 0)
                {
                    return(BadRequest("No files received from the upload."));
                }

                if (storageConfig.AccountKey == string.Empty || storageConfig.AccountName == string.Empty)
                {
                    return(BadRequest("Could not find Azure Storage AccountKey and AccountName."));
                }

                if (storageConfig.ImageContainer == string.Empty)
                {
                    return(BadRequest("Could not find Azure Blob Storage Image Container Name."));
                }

                List <string> fileNames = new List <string>();

                foreach (var formFile in files)
                {
                    if (StorageHelper.IsImage(formFile))
                    {
                        if (formFile.Length > 0)
                        {
                            using (Stream stream = formFile.OpenReadStream())
                            {
                                string fileName = Guid.NewGuid().ToString() + Path.GetExtension(formFile.FileName);

                                isUploaded = await StorageHelper.UploadFileToStorage(stream, fileName, storageConfig);

                                fileNames.Add(fileName);
                            }
                        }
                    }
                    else
                    {
                        return(new UnsupportedMediaTypeResult());
                    }
                }

                if (isUploaded)
                {
                    if (storageConfig.ThumbnailContainer != string.Empty)
                    {
                        // return new AcceptedAtActionResult("GetThumbNails", "Images", null, null);
                        return(new ObjectResult(fileNames));
                    }
                    else
                    {
                        return(new AcceptedResult());
                    }
                }
                else
                {
                    return(BadRequest("Could not upload image to Azure Storage."));
                }
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
        public async Task <IActionResult> Upload(ICollection <IFormFile> files)
        {
            bool isUploaded = false;

            try
            {
                if (files.Count == 0)
                {
                    return(BadRequest("No files received from the upload"));
                }

                if (storageConfig.AccountKey == string.Empty || storageConfig.AccountName == string.Empty)
                {
                    return(BadRequest("sorry, can't retrieve your azure storage details from appsettings.js, make sure that you add azure storage details there"));
                }

                if (storageConfig.ImageContainer == string.Empty)
                {
                    return(BadRequest("Please provide a name for your image container in the azure blob storage"));
                }

                foreach (var formFile in files)
                {
                    if (StorageHelper.IsImage(formFile))
                    {
                        if (formFile.Length > 0)
                        {
                            using (Stream stream = formFile.OpenReadStream())
                            {
                                string fileName = StorageHelper.UseLowerCaseImageExtension(formFile);

                                isUploaded = await StorageHelper.UploadFileToStorage(stream, fileName, storageConfig);
                            }
                        }
                    }
                    else
                    {
                        return(new UnsupportedMediaTypeResult());
                    }
                }

                if (isUploaded)
                {
                    if (storageConfig.ThumbnailContainer != string.Empty)
                    {
                        return(new AcceptedAtActionResult("GetThumbNails", "Images", null, null));
                    }

                    else
                    {
                        return(new AcceptedResult());
                    }
                }
                else
                {
                    return(BadRequest("Look like the image couldnt upload to the storage"));
                }
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }