Krishna
8 months agoValued Contributor
AWS S3 SDK
Hello - Does anyone used the AWS SDK (Dot Net) to download the file to the OS batch harvest folder? using SIC if so, could you please provide high level steps?
Any Help would be appreciated.
- 7 months ago
Krishna,
SIC is needed to establish secure access to the client network. Since AWS is hosted in the cloud (outside of the client network) you can just connect to it directly from OneStream using a Business Rule. you will need to request OneStream support to make the Amazon libraries available on the server side.
it should probably look something like this:
Imports SystemImports System.DataImports System.Data.CommonImports System.IOImports System.Collections.GenericImports System.GlobalizationImports System.LinqImports Microsoft.VisualBasicImports System.Windows.FormsImports System.Net.MailImports OneStream.Shared.CommonImports OneStream.Shared.WcfImports OneStream.Shared.EngineImports OneStream.Shared.DatabaseImports OneStream.Stage.EngineImports OneStream.Stage.DatabaseImports OneStream.Finance.EngineImports OneStream.Finance.DatabaseImports Amazon.S3Namespace OneStream.BusinessRule.Extender.Retrieve_AWS_filesPublic Class MainClassPublic Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As ExtenderArgs) As ObjectTrySelect Case args.FunctionTypeCase Is = ExtenderFunctionType.Unknown, ExtenderFunctionType.ExecuteDataMgmtBusinessRuleStepRetrieve_Files_From_AWS(si)End SelectReturn NothingCatch ex As ExceptionThrow ErrorHandler.LogWrite(si, New XFException(si, ex))End TryEnd FunctionFunction Retrieve_Files_From_AWS(si As SessionInfo) As List(Of String)Dim AWS_Client = Me.AWS_Client(si)Dim BucketName As String = "bucket-name"Dim Prefix As String = "some/directory"'Get filenames from AWS bucketDim AWSDirectoryInfo As New IO.S3DirectoryInfo(AWS_Client, BucketName, Prefix)Dim Harvest_Folder_Path As String = BRApi.Utilities.GetFileShareFolder(si, FileShareFolderTypes.BatchHarvest, Nothing)For Each file In AWSDirectoryInfo.GetFiles()file.MoveToLocal(Harvest_Folder_Path & "/" & file.Name)NextAWS_Client.Dispose()Return NothingEnd FunctionFunction AWS_Client(si As SessionInfo) As AmazonS3Client'AWS CredentialsDim AccessKey As String = "ASDLKFASJFA;LDSF;LAJF;LSA"Dim SecretKey As String = ";lakdsf;laf;lajds;lfajds;lfl"'Create Amazon S3 Client ObjectDim awsClient As New AmazonS3Client(AccessKey, SecretKey, Amazon.RegionEndpoint.USEast1)Return awsClientEnd FunctionEnd ClassEnd Namespace