internal static bool CreateDefaultSettingsFile(string projectId) { try { var result = S3UploadHelper.GetAssetFromS3(EnvironmentConstants.ApplicationConfiguration.AWSS3Configuration.AWS_AccessKey, EnvironmentConstants.ApplicationConfiguration.AWSS3Configuration.AWS_SecretKey, AmazonAWSConstants.ResourceBucketName, string.Format(Kitsune.API2.EnvConstants.Constants.ProjectDefaultSettingsFile, projectId)); string fileContent = String.Empty; if (result != null && result.IsSuccess) { fileContent = result.File != null ? result.File.Content : String.Empty; } CreateOrUpdateProjectConfigRequestModel request = new CreateOrUpdateProjectConfigRequestModel() { File = new ConfigFile { Content = fileContent }, ProjectId = projectId }; CreateOrUpdateProjectConfig(request); return(true); } catch (Exception ex) { return(false); } }
internal static bool CreateDefaultStaticIndexResource(string projectId) { try { if (_kitsuneServer == null) { InitializeConnection(); } var ResourceCollection = _kitsuneDatabase.GetCollection <KitsuneResource>(KitsuneResourceCollectionName); var dateTime = DateTime.Now; #region foreach (var file in Kitsune.API2.EnvConstants.Constants.ProjectDefaultFiles) { KitsuneResource resourceCollection = new KitsuneResource { ProjectId = projectId, SourcePath = file, CreatedOn = dateTime, UpdatedOn = dateTime, ResourceType = GetResourceType(file), IsStatic = true, Version = 1, IsDefault = file.Contains("/index.html") }; ResourceCollection.InsertOne(resourceCollection); //upload the object to S3 var result = S3UploadHelper.GetAssetFromS3(EnvironmentConstants.ApplicationConfiguration.AWSS3Configuration.AWS_AccessKey, EnvironmentConstants.ApplicationConfiguration.AWSS3Configuration.AWS_SecretKey, AmazonAWSConstants.ResourceBucketName, $"static/defaults_new{file}"); string defaultHtmlData = String.Empty; if (result != null && result.IsSuccess) { defaultHtmlData = result.File.Content; Byte[] byteHtmlData = Encoding.ASCII.GetBytes(defaultHtmlData); var saveResult = S3UploadHelper.SaveAssetsAndReturnObjectkey(EnvironmentConstants.ApplicationConfiguration.AWSS3Configuration.AWS_AccessKey, EnvironmentConstants.ApplicationConfiguration.AWSS3Configuration.AWS_SecretKey, projectId + file, byteHtmlData, AmazonAWSConstants.SourceBucketName, result.File.ContentType); var demosaveResult = S3UploadHelper.SaveAssetsAndReturnObjectkey(EnvironmentConstants.ApplicationConfiguration.AWSS3Configuration.AWS_AccessKey, EnvironmentConstants.ApplicationConfiguration.AWSS3Configuration.AWS_SecretKey, projectId + "/cwd" + file, byteHtmlData, AmazonAWSConstants.DemoBucketName, result.File.ContentType); } } #endregion return(true); } catch (Exception ex) { return(false); } }