I want to upload a file using uploadTask(with:fromFile:) on iOS (device and simulator).
I tried to save/copy the file to the users documents directory, the temp and caches directory, but for every directory uploadTask terminates the app with 'NSInvalidArgumentException', reason: 'Cannot read file at file:xxx -- file:///'
What directory/path do you have to use to get this working?
Or do you have to add something to the Info.plist or at Signing & Capabilities for the app/project?
Hello Quinn,
Thanks for the feedback.
I have investigated the URL handling in the code and found a problem converting the URL to a string and back to a URL for using with uploadTask(with:fromFile:).
After fixing the code for converting the URL uploadTask(with:fromFile:) now works as expected.
The provided error message 'NSInvalidArgumentException', reason: 'Cannot read file at file:*** -- file:///' from uploadTask(with:fromFile:) did not lead to look for a problem with the format/content of the URL. To me, the error message had sounded more like an access problem.
Thanks a lot for your support!