Esempio n. 1
0
        public async Task <IActionResult> UploadImage(IFormFile imageFile, [FromForm] bool isNotifiableByEmail)
        {
            bool isUploaded = false;

            try
            {
                if (imageFile == null)
                {
                    return(BadRequest("Nincs fogadott feltöltendő fájl"));
                }
                if (AccountKey == string.Empty || AccountName == string.Empty)
                {
                    return(BadRequest("Nem tudjuk feloldani az Azure tárhelyed, csekkold hogy van megadva accountName és accountKey!"));
                }

                if (UploadService.IsImage(imageFile) && imageFile.Length > 0)
                {
                    using (Stream stream = imageFile.OpenReadStream())
                    {
                        isUploaded = await UploadService.UploadImageToPersonalBlobStorage(stream, DateTime.Now.ToString("yyMMddHHmmssffffff") + imageFile.FileName, AzureConnectionString, await GetCurrentUserIdAsync(), isNotifiableByEmail);
                    }
                }
                else
                {
                    return(new UnsupportedMediaTypeResult());
                }

                return(new OkResult());
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }