Пример #1
0
        public async Task <BaseDeveloperResponse> SaveFile(SimpleJsonRequest request,
                                                           BaseDeveloperResponse baseDeveloperResponse = null)
        {
            var returner = baseDeveloperResponse ?? new BaseDeveloperResponse();

            _logger.LogDebug($"Execution started");
            _logger.LogDebug($"request.Id : {request.Id}");
            _logger.LogDebug(
                $"request.MetaDatas : {string.Join(',', request.MetaDatas.Select(x => $"[{x.Key} : {x.Value}]"))}");

            var returnPaths = new List <string>();

            foreach (var contentFile in request.ContentFiles)
            {
                if (contentFile.ContentFile.Any())
                {
                    var filePath = Path.Combine(_targetFilePath, contentFile.FileName);

                    await using (var memoryStream = new FileStream(filePath, FileMode.Create))
                    {
                        using (MemoryStream ms = new MemoryStream(contentFile.ContentFile))
                        {
                            await ms.CopyToAsync(memoryStream);

                            await memoryStream.FlushAsync();
                        }
                        returnPaths.Add(filePath);
                    }
                }
            }

            return(returner.Stop($"Document created at {string.Join(" , ", returnPaths)}"));
        }
Пример #2
0
        public async Task <IActionResult> MultiPartFormTestMultiple([FromBody] SimpleJsonRequest request)
        {
            try
            {
                var data = await _simpleJsonService.SaveFile(request);

                return(Ok(data));
            }
            catch (Exception ex)
            {
                return(Problem(ex.Message, statusCode: 500));
            }
        }
Пример #3
0
 public TestController(IDistributedCache cacheService)
 {
     requestService = new SimpleJsonRequest(cacheService);
 }
Пример #4
0
        public string GetImage(string url)
        {
            var x = SimpleJsonRequest.GetImageAsync(url).Result;

            return(x);
        }