Getting the path to LocalStorage

I've been struggling to get the root path of local storage provider. E.g. /private/var/mobile/Containers/Shared/AppGroup/0C7A3DB2-BA52-4B54-XXXX-E95027E673A9/File Provider Storage.

Users can grant access to folders for our drum sampler app in order to use audio samples without importing them and because we have facilities to quickly explore samples.

There are two reasons why i want to use this:

  1. To display "On My iPad"/"On My iPhone" when users explore the file
  2. Preferably in project files we would like to store paths to files in a way that projects still open correctly after re-installation of a user's device.

After poking around it seems that File Provider Storage is basically just an app-group named group.com.apple.FileProvider.LocalStorage however we don't have permissions to join that group.

Accepted Reply

In both examples i think it'd be very confusing for users to see "File Provider Storage" instead of "On My iPhone"

So, at a high level, you’ve got a URL from the document picker and you’re looking for a way to get the user-visible name of that URL’s ‘container’?

I’m not sure if there’s a good way to do that. If no one else chimes in, I encourage you to open a DTS tech support incident and one of my colleagues can research this in more depth.

unfortunately the document file type is cross-platform and doesn't easily lend itself to these kind of extensions

Yeah, you’re not the first person to hit this problem, although I more often seen it with folks working on Mac apps.

One option here is to store the bookmarks separately from the document. This allows your app to work with a document locally on a single device. However, the user experience is less than ideal if they move the document to a new device.

Also since we use access granted to whole directories

To be clear, security-scope bookmarks are not limited to files; if you have access to a directory, you can create one for that directory.

Share and Enjoy

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

  • Thank you. Yeah i guess a minimal solution to the first problem would be to to have NSURL.getResourceValue for key NSURLLocalizedNameKey return something more useful. I'll wait to see if there is more input to this thread and file DTS incident else.

Add a Comment

Replies

1. To display "On My iPad"/"On My iPhone" when users explore the file

I don’t understand this. Please elaborate.

2. Preferably in project files we would like to store paths to files in a way that projects still open correctly after re-installation of a user's device.

The standard way to do this is to store a security-scoped bookmark in your project. You can then resolve the bookmark to regain access to the original file.

Is that not working for you?

Share and Enjoy

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

  • Ad (1): What i mean is that we display the origin of the sample next to the waveform. See https://pasteboard.co/dwspP4Jk5tjQ.png and also we provide a browser for users to quickly find and preview samples as seen here: https://pasteboard.co/dJVzuM7mG1WC.png In both examples i think it'd be very confusing for users to see "File Provider Storage" instead of "On My iPhone"

    Ad (2): I've experimented with security-scoped bookmarks but unfortunately the document file type is cross-platform and doesn't easily lend itself to these kind of extensions. Also since we use access granted to whole directories and users can switch samples within the app (without using UIDocumentPickerViewController) we don't necessarily haven a security scoped bookmark. That being said we could generate a non-security scoped bookmark using NSURL.bookmarkDataWithOptions

Add a Comment

In both examples i think it'd be very confusing for users to see "File Provider Storage" instead of "On My iPhone"

So, at a high level, you’ve got a URL from the document picker and you’re looking for a way to get the user-visible name of that URL’s ‘container’?

I’m not sure if there’s a good way to do that. If no one else chimes in, I encourage you to open a DTS tech support incident and one of my colleagues can research this in more depth.

unfortunately the document file type is cross-platform and doesn't easily lend itself to these kind of extensions

Yeah, you’re not the first person to hit this problem, although I more often seen it with folks working on Mac apps.

One option here is to store the bookmarks separately from the document. This allows your app to work with a document locally on a single device. However, the user experience is less than ideal if they move the document to a new device.

Also since we use access granted to whole directories

To be clear, security-scope bookmarks are not limited to files; if you have access to a directory, you can create one for that directory.

Share and Enjoy

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

  • Thank you. Yeah i guess a minimal solution to the first problem would be to to have NSURL.getResourceValue for key NSURLLocalizedNameKey return something more useful. I'll wait to see if there is more input to this thread and file DTS incident else.

Add a Comment