12-02-2021 12:44 PM
When running a Data Mgmt Data Extract step, you can chose where you want the file saved:
However, the name you provide always starts under the File Share\Applications\[App Name]\DataManagement\Export\[User Name] folder. So, the above extract would show up as File Share\Applications\MyApp\DataManagement\Export\Phil\20211202\CubeData.csv
We need these extracts to be available to users who do not have access to the individual user folders on the File Share (i.e. - they aren't Admins)
Is there a way to have the Data Extract saved to a truly user defined location, like Application Database\Documents\Public\DataExtracts? How could this be done? If you run the extract from a business rule are there arguments you can pass into the data management call to override the export path? Or is there a way to programmatically move the file after it's been created?
Thanks,
01-18-2022 07:53 AM
Hi Phil,
You can export the file to File Share folder and then run a copy step to copy the file to Documents/Public/xyz folder. Here is a sample code:
If args.CustomCalculateArgs.FunctionName.XFEqualsIgnoreCase("Move_File_from_FS_to_Public_Folder")
Dim configSettings As AppServerConfigSettings = AppServerConfig.GetSettings(si)
Dim xfolderPath As String = FileShareFolderHelper.GetDataManagementExportUsernameFolderForApp(si,True, configsettings.fileShareRootFolder,si.AppToken.AppName)
Dim DestinationPath As String = "Cell_Details" '<-- This is the destination folder
Dim ParentPath As String = "Documents/Public" '<-- App Folder path where new folder will be added, may be updated
Dim fileToMove As String = "Cell_Details.csv"
Dim fileBytes As Byte() = File.ReadAllBytes(xfolderPath & "/" & fileToMove)
Dim targetDir As String = BRApi.FileSystem.GetFolder(si, FileSystemLocation.ApplicationDatabase, ParentPath & "/" & DestinationPath).XFFolder.FullName
Using dbConnApp As DBConnInfo = BRApi.Database.CreateApplicationDbConnInfo(si)
'Save file in User's Temp folder in application DB
'(This will be cleaned up automatically be OneStream platform When user's session expires)
Dim dbFileInfo As New XFFileInfo(FileSystemLocation.ApplicationDatabase, fileToMove, targetDir, XFFileType.Unknown)
dbFileInfo.ContentFileContainsData = True
dbFileInfo.ContentFileExtension = dbFileInfo.Extension
Dim dbFile As New XFFile(dbFileInfo, String.Empty, fileBytes)
BRApi.FileSystem.InsertOrUpdateFile(si, dbFile)
End Using
End If