Here is the procedure I use to save a TXT file
Private Sub exportTxt(text As String)
'write
File.WriteString(xui.DefaultFolder, "exp1.txt", text)
'Save as
Dim in As InputStream = File.OpenInput(xui.DefaultFolder, "exp1.txt")
Wait For (FileHandler1.SaveAs(in, "text/plain", "YourFile.txt")) Complete (Success As Boolean)
If Success Then
toast.Show("File saved successfully")
Else
toast.Show("File not saved")
End If
End Sub
In your code, you save a JPEG as TXT with OCTET/STREAM. MIME must match file type
Ex.
"text/plain", "YourFile.txt"
"application/pdf", "YourFile.pdf"
"image/png", "YourFile.png"
"image/jpeg", "YourFile.jpg"