/// <summary> /// Save the request in S3 for use in the background task, rather than in the Database /// </summary> /// <param name="request">Request to be saved</param> /// <returns>A Guid to be passed in to the background task</returns> private Guid SaveRequest(ScheduleJobRequest request) { var guid = Guid.NewGuid(); var data = JsonConvert.SerializeObject(request, Formatting.None); var bytes = Encoding.UTF8.GetBytes(data); using (var ms = new MemoryStream(bytes)) { _transferProxy.Upload(ms, $"{S3_SCHEDULE_SAVE_LOCATION}/{guid}"); } return(guid); }
/// <summary> /// Writes the importedFile to S3 /// if file exists, it will be overwritten /// returns FileDescriptor for backwards compatability /// </summary> /// <returns></returns> public static FileDescriptor WriteFileToS3Repository( Stream fileContents, string projectUid, string filename, bool isSurveyedSurface, DateTime?surveyedUtc, ILogger log, IServiceExceptionHandler serviceExceptionHandler, ITransferProxy persistantTransferProxy) { var s3FullPath = GetS3FullPath(projectUid, filename, isSurveyedSurface, surveyedUtc); try { persistantTransferProxy.Upload(fileContents, s3FullPath); } catch (Exception e) { serviceExceptionHandler.ThrowServiceException(HttpStatusCode.InternalServerError, 57, "transferProxy.Upload()", e.Message); } log.LogInformation($"WriteFileToS3Repository. Process add design :{s3FullPath}, for Project:{projectUid}"); var finalFilename = s3FullPath.Split("/")[1]; return(FileDescriptor.CreateFileDescriptor(string.Empty, string.Empty, finalFilename)); }