iOS Question Can not open file from attachment.

mrossen

Active Member
Licensed User
Hi,

I try to open a file attachment, but when I get the file path in my app it seems to be broken,

I want to save the file in my app folder. Can this be done or do I have to read the file and then save it?

I use this example.

B4X:
Private Sub Application_OpenUrl (Url As String, Data As Object) As Boolean
    If Url.StartsWith("file://") Then
        Dim f As String = Url.SubString(7) 'remove the file:// scheme.
        Try
            Msgbox(File.ReadString("", f), "")
        Catch
            Log(f)
            Msgbox("Error loading file", "")
        End Try
    End If
    Return True
End Sub
But it ends here

B4X:
Application_Start
Application_Active
Application_Inactive
Application_Background
Can't end BackgroundTask: no background task exists with identifier 2 (0x2), or it may have already been ended. Break in UIApplicationEndBackgroundTaskError() to debug.
openURL: file:///private/var/mobile/Containers/Data/Application/305537A7-D7E4-40EC-A745-8DD02E52CF33/Documents/Inbox/1530012%201%20Toyota%20Avensis%2025x%20serie%20model%202004%20-%202009-7.lps, com.apple.sharingd, (null)
Application_Openurl
Error occurred on line: 58 (Main)
Error reading file: Error Domain=NSCocoaErrorDomain Code=260 "The file “1530012%201%20Toyota%20Avensis%2025x%20serie%20model%202004%20-%202009-7.lps” couldn’t be opened because there is no such file." UserInfo={NSFilePath=/private/var/mobile/Containers/Data/Application/305537A7-D7E4-40EC-A745-8DD02E52CF33/Documents/Inbox/1530012%201%20Toyota%20Avensis%2025x%20serie%20model%202004%20-%202009-7.lps, NSUnderlyingError=0x283351c50 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
Stack Trace: (
  CoreFoundation       1B9B1E61-8CB4-3903-9870-402C3DE959BB + 1227356
  libobjc.A.dylib      objc_exception_throw + 56
  CoreFoundation       1B9B1E61-8CB4-3903-9870-402C3DE959BB + 135616
  iMail                -[B4IFile ReadString2:::] + 532
  iMail                -[B4IFile ReadString::] + 120
  CoreFoundation       1B9B1E61-8CB4-3903-9870-402C3DE959BB + 1252384
  CoreFoundation       1B9B1E61-8CB4-3903-9870-402C3DE959BB + 7472
  iMail                +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1608
  iMail                -[B4IShell runMethod:] + 448
  iMail                -[B4IShell raiseEventImpl:method:args::] + 1648
 iMail                -[B4IShellBI raiseEvent:event:params:] + 1580
 iMail                -[B4IAppDelegate application:openURL:sourceApplication:annotation:] + 920
 UIKitCore            27D3041D-A1DE-3C3A-8DC0-994B5982DC49 + 10532196
 UIKitCore            27D3041D-A1DE-3C3A-8DC0-994B5982DC49 + 10530996
 UIKitCore            27D3041D-A1DE-3C3A-8DC0-994B5982DC49 + 10582728
 UIKitCore            27D3041D-A1DE-3C3A-8DC0-994B5982DC49 + 275668
 UIKitCore            27D3041D-A1DE-3C3A-8DC0-994B5982DC49 + 279992
 UIKitCore            27D3041D-A1DE-3C3A-8DC0-994B5982DC49 + 5993032
 FrontBoardServices   CFAE1F5E-2396-3881-A68B-1B3285B64217 + 53832
 FrontBoardServices   CFAE1F5E-2396-3881-A68B-1B3285B64217 + 204072
 FrontBoardServices   CFAE1F5E-2396-3881-A68B-1B3285B64217 + 93956
 FrontBoardServices   CFAE1F5E-2396-3881-A68B-1B3285B64217 + 203868
 libdispatch.dylib    A3849F96-1C9F-36C5-A15F-70C566F14CFF + 377220
 libdispatch.dylib    A3849F96-1C9F-36C5-A15F-70C566F14CFF + 20440
 FrontBoardServices   CFAE1F5E-2396-3881-A68B-1B3285B64217 + 353304
 FrontBoardServices   CFAE1F5E-2396-3881-A68B-1B3285B64217 + 352484
 FrontBoardServices   CFAE1F5E-2396-3881-A68B-1B3285B64217 + 353804
 CoreFoundation       1B9B1E61-8CB4-3903-9870-402C3DE959BB + 694784
 CoreFoundation       1B9B1E61-8CB4-3903-9870-402C3DE959BB + 694616
 CoreFoundation       1B9B1E61-8CB4-3903-9870-402C3DE959BB + 692464
 CoreFoundation       1B9B1E61-8CB4-3903-9870-402C3DE959BB + 672316
 CoreFoundation       CFRunLoopRunSpecific + 464
 GraphicsServices     GSEventRunModal + 104
 UIKitCore            UIApplicationMain + 1936
 iMail                main + 124
 libdyld.dylib        2E3F4750-8B67-398B-8530-8417651B1718 + 4960
)
/private/var/mobile/Containers/Data/Application/305537A7-D7E4-40EC-A745-8DD02E52CF33/Documents/Inbox/1530012%201%20Toyota%20Avensis%2025x%20serie%20model%202004%20-%202009-7.lps
Application_Foreground
Application_Active
 

mrossen

Active Member
Licensed User
Hi Erel

I already have. Line 3 from bottom

B4X:
/private/var/mobile/Containers/Data/Application/305537A7-D7E4-40EC-A745-8DD02E52CF33/Documents/Inbox/1530012%201%20Toyota%20Avensis%2025x%20serie%20model%202004%20-%202009-7.lps
Mogens
 
Top