Exemplo n.º 1
0
        public async Task <IActionResult> AddFile(Guid batchId, string filename)
        {
            try
            {
                var batchFile = await batchService.GetBatchById(batchId);

                if (batchFile == null)
                {
                    return(BadRequest(modelValidation.ValidateModel("400", "Batch id incorrect", "Incorrect batch id is provided")));
                }
                else
                {
                    var mimeType    = HttpContext.Request.Headers["X-MIME-Type"];
                    var contentSize = HttpContext.Request.Headers["X-Content-Size"];
                    var batchfile   = await batchService.AddFiles(configuration["storageAccountName"].ToString(), configuration["storageKey"].ToString(), batchId, filename, Convert.ToInt32(contentSize), mimeType);

                    if (batchfile == true)
                    {
                        return(Ok($"Created"));
                    }
                    else
                    {
                        return(BadRequest("either file name is already exists or incorrect mime type is provided"));
                    }
                }
            }
            catch (Exception ex)
            {
                logger.LogError(ex.Message.ToString());
                return(StatusCode(500, $"Internal server error: {ex}"));
            }
        }