Let’s focus on the device case for the moment, because once you get that working it’s likely that the simulator will just work as well.
In general you can upload a file as long as you have read access to it. A classic example of this is your app’s Documents directory. If you you get this error while trying to upload a file in your Documents directory, you have a bug in your code.
Or do you have to add something to the Info.plist
or at Signing &
Capabilities for the app/project?
No. This will work out of the box.
The most common cause of this error is a mixup between file paths and file URLs. If you get a file path using a routine like NSSearchPathForDirectoriesInDomains
and you need a file URL for that, it’s important to call URL(fileURLWithPath:)
. If call URL(string:)
with a file path, you won’t get the right URL.
IMO the best way to avoid that problem is to always work in ‘URL
space’. That has a bunch of other advantages, for example, when dealing with security scopes.
Anyway, if this isn’t the problem please post back with more details about how to build the URL
that you pass to the upload task.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"