I've been able to successfully do all the steps needed to access external files like CSV as well as my own custom extension types. All end up triggering Application_OpenUrl as they should, and I can successfully extract the file name. But for some reason, the byte length of Data ends up as 9 no matter what I do.
For example, I receive a CSV file via email and send it to my app, triggering Application_OpenUrl. The file name is fine, but I see no data. The CSV file attached to the email is perfectly OK and I can open it with a spreadsheet, so the file itself is not a problem.
Here's my code:
What am I doing wrong?
For example, I receive a CSV file via email and send it to my app, triggering Application_OpenUrl. The file name is fine, but I see no data. The CSV file attached to the email is perfectly OK and I can open it with a spreadsheet, so the file itself is not a problem.
Here's my code:
B4X:
Private Sub Application_OpenUrl (Url As String, Data As Object) As Boolean
'extract filename from Url
Dim fname As String
fname=Url.SubString(Url.LastIndexOf("/"))
'convert data object
Dim ser As B4XSerializator
Dim fbytes() As Byte
fbytes=ser.ConvertObjectToBytes(Data)
Log(fbytes.Length) '(ALWAYS RESULTS IN "9")
'write data into file in /Download folder
Dim out As OutputStream = File.OpenOutput(SafeDir & "/" & ImportDir, fname, False)
out.WriteBytes(fbytes, 0, fbytes.Length)
out.Close
Return True
End Sub
What am I doing wrong?
Last edited: