Downloading files to external storage

Can we download a file directly into a connected external storage like a pendrive without downloading it into App Sandbox environment first and then copying the file to external storage, in case of larger files.

If you are referencing the ability of FileProvider to have domains on external drives in macOS 15, then yes. (https://developer.apple.com/documentation/fileprovider/nsfileproviderdomain/init(displayname:userinfo:volumeurl:)?language=objc)

You can use the -[NSFileProviderManager temporaryDirectoryURLWithError:] method. This will return a URL on the same volume as the domain. (https://developer.apple.com/documentation/fileprovider/nsfileprovidermanager/temporarydirectoryurl()?language=objc)

Similarly, you can store your apps database and other internal state at -[NSFileProviderManager stateDirectoryURLWithError:], which will also be on the same volume as the domain. (https://developer.apple.com/documentation/fileprovider/nsfileprovidermanager/statedirectoryurl()?language=objc)

Sorry. I could have been more specific about the question.

I am asking if in iOS do we have the capability to download a file from an application directly into Local storage or external storage.

The process I am familiar with is:

  1. The downloading happens in App Sandbox environment .
  2. Then copy the file from App Sandbox environment to the external storage or Local storage.

Is there a possibility that we eliminate the step of downloading it into App Sandbox and can directly download it to the Local Storage or External storage, if possible with the user chosen location?

What API are you using to run the download? And, if it’s URLSession, are you using a background session?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Yes. I am using NSURLSession with backgroundSessionConfigurationWithIdentifier.

Is there any possible way, that we can skip downloading the file into a temporary location, as mentioned here in downloadTask , and directly download it into external storage?

Downloading files to external storage
 
 
Q