示例#1
0
 public void SaveJsonToS3(SaveJsonToS3Request jsonRequest)
 {
     try
     {
         _awsS3Client.SaveJsonToS3(jsonRequest);
     }
     catch (Exception ex)
     {
         throw new JsonFileCouldNotBeSavedToS3Exception($"The JSON file could not be save to S3 for the following reason - {ex.Message}, {ex.InnerException}");
     }
 }
 public IActionResult SaveJsonToS3([FromBody] SaveJsonToS3Request request)
 {
     try
     {
         _getSaveJsonToS3UseCase.SaveJsonToS3Case(request);
         return(CreatedAtAction("SaveS3Successful", null));
     }
     catch (JsonFileCouldNotBeSavedToS3Exception ex)
     {
         return(StatusCode(500, ex.Message));
     }
 }
示例#3
0
 public void SaveJsonToS3(SaveJsonToS3Request jsonRequest)
 {
     using (AmazonS3Client _s3Client = new AmazonS3Client(RegionEndpoint.EUWest2))
     {
         byte[] _byteArray = Encoding.ASCII.GetBytes(jsonRequest.JsonData);
         using (var stream = new MemoryStream(_byteArray))
         {
             var objectRequest = new PutObjectRequest
             {
                 BucketName  = jsonRequest.BucketName,
                 Key         = jsonRequest.FileName,
                 ContentType = "application/json",
                 InputStream = stream,
             };
             var response = _s3Client.PutObjectAsync(objectRequest).Result;
         }
     }
 }
示例#4
0
 public void SaveJsonToS3Case(SaveJsonToS3Request request)
 {
     request.FileName = SaveJsonToS3Helper.EnsureFileIsJson(request.FileName);
     _saveJsonToS3Gateway.SaveJsonToS3(request);
 }