The OneStream Community is temporarily frozen until June 29th due to the ongoing maintenance. Please read the blog post here to learn more.
Forum Discussion
Sergey
OneStream Employee
3 years agoSaveFileBytesToUserTempFolder returning an error message
Hi,
I am trying to use the Business Rule API "SaveFileBytesToUserTempFolder" in order to open a file stored as a byte in a datatable.
This is exactly like in the "Reporting Compliance" dashboard, where the file is stored as bytes in a datatable. I am actually using the exact same business rule !
However, there is an issue in my case. My business rule that is used to view the document works fine until the very last step... this is the one causing the error ( I have tested FileName and FileBytes fields and these exist) :
BRApi.Utilities.SaveFileBytesToUserTempFolder(si, si.UserName, dt(0)("FileName"), dt(0)("FileBytes"))
Error message :
An error occurred while receiving the HTTP response to http://localhost:50002/OneStreamApp/SVC/XFFileSystem.svc. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.
The underlying connection was closed: An unexpected error occurred on a receive.
Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
An existing connection was forcibly closed by the remote host (Socket Error Number 10054).
The exact same file is used in Reporting Compliance and I can view it. Am I missing something ?
I don't find any documentation on this function ...
Regards,
12 Replies
- Gidon_AlbertContributor II
We ended up saving the data to the user's folder instead of the temp folder:
'Export the data Dim fileName As String = "IC_Detail.csv" Dim filePath As String = "Documents/Users/" & StringHelper.RemoveSystemCharacters(si.UserName,False,False) 'Export csvContent to User Folder Dim fileBytes() As Byte = system.Text.Encoding.Unicode.GetBytes(csvContent.ToString) Dim fileDataInfo As New XFFileInfo(FileSystemLocation.ApplicationDatabase, fileName, filePath) Dim fileData As New XFFile(fileDataInfo, String.Empty, fileBytes) brapi.FileSystem.InsertOrUpdateFile(si, fileData) - Gidon_AlbertContributor II
Unfortunately, no resolution yet.
- WernerNContributor II
That is too bad. Maybe we can figure it out next week at Splash.
- NidhiMangtaniContributor III
Hi,
We are also facing the same error. If no resolution, do we have any workaround for this issue?
- NicolasArgenteValued Contributor
Hi Sergey!
Have you tried browsing to http://localhost:50002/OneStreamApp/SVC/XFFileSystem.svc you might find more info.Also did you check that the extension is on the filename? My understanding is that the fileBytes is already good on your side? Have you tested it? for example using https://base64.guru/converter/decode/file
Or Have you tried with the exact same base64 (byte) than with the other file or see if there is a difference? Have you hard coded the fileName instead to "test.csv" or "test.xls" depending on the filetype?
'Export Register
Dim fileName As String = "Register.csv"'Export CSV to User Temp Folder
Dim csv As String = Me.CreateRegisterTableCSVText(si, profileName, scenarioName, timeName).ToString
Dim fileBytes As Byte() = Encoding.UTF8.GetBytes(csv)
BRApi.Utilities.SaveFileBytesToUserTempFolder(si, si.UserName, fileName, fileBytes) - Gidon_AlbertContributor II
We're getting a similar error:
Here's the section of the code that gets the CSV string that is converted to Byte:
Dim ds As New DataSet Dim csvContent As New Text.StringBuilder Dim qualifier As String = StageConstants.ParserDefaults.DefaultQuoteCharacter Dim delimiter As String = StageConstants.ParserDefaults.DefaultDelimiter csvContent.AppendLine("Intercompany Detail") csvContent.AppendLine("Workflow Profile: " & WFProfile) csvContent.AppendLine("Workflow Scenario: " & WFScenario) csvContent.AppendLine("Workflow Time: " & WFTime) Dim methodQuery As String = "{" & WFProfile & "}{" & WFScenario & "}{" & WFTime & "}{}{}{V#[YTD]}{True}{}{}{}{}{}" If Not String.IsNullOrEmpty(WFTime) Then Using dbConnApp As DbConnInfo = BRApi.Database.CreateApplicationDbConnInfo(si) ds = BRApi.Database.ExecuteMethodCommand(dbConnApp, XFCommandMethodTypeId.ICMatchingForWorkflowUnitMultiPlug, methodQuery, "PlugAccounts", Nothing) "Get the IC Detail" 'Export the data Dim fileName As String = "IC_Detail.csv" '********* debug info ********* brapi.ErrorLog.LogMessage(si, "ADU_SoluitonHelper.Extract_WFU_IC_Matching_Plug_Accounts" & vbCrLf & "csvContent: " & csvContent.Length) '****************************** 'Export csvContent to User Temp Folder Dim fileBytes As Byte() = Encoding.UTF8.GetBytes(csvContent.ToString) ' Threading.Thread.Sleep(5000) ' 5000 milliseconds = 5 seconds BRApi.Utilities.SaveFileBytesToUserTempFolder(si, si.UserName, fileName, fileBytes) End Using End IfThe application is on the cloud so we can't use http://localhost:50002/OneStreamApp/SVC/XFFileSystem.svc
- WernerNContributor II
Gideon,
Hope all is well. Did you ever get a resolution to this problem.
I have the same error when i try to download an xlsx from the Public folder with a cloned UTM button that works perfect in UTM but not in my dashboard.
-w
- JamesReesNew Contributor III
Hi All,
Did anybody get any resolution to their .csv export problem? We're facing similar issues, but it affects some users and not others....and we can't see what the common theme is between them.
Thanks
- ckattookaranValued Contributor
What if you try to save it as an application file instead of a temp user file? Does that work?
- NidhiMangtaniContributor III
Hi,
In our case, we are posting CSV file to Batch Harvest folder, not user temp folder. Do we have any samples to create application CSV file through BR?
- NidhiMangtaniContributor III
All,
We could fix this error. It is essentially occurring when row count is 0 and we are trying to write that datatable content to a CSV file. Check the row count of your datatable, if its 0, just add a blank row to your datatable and then let a blank CSV file with just headers be created and opened by the system
Hope this helps.
- JeffTNew Contributor
Hi All,
I ran into the same issue earlier today and managed to get it working, so I wanted to share the solution in case it helps others.
In my case, the error was caused by an invalid path name. The SaveFileBytesToUserTempFolder function saves the file to the temp folder, and then my dashboard button tries to open that path. I was using a |UserName| substitution variable in the Navigation Arguments. However, since the username contained spaces, the system couldn't locate the path correctly.
To resolve this, I created an XFBR rule to trim the spaces from the username, and now everything works as expected.
Related Content
- 2 months ago
- 2 years ago
- 3 years ago