3

I store video files in the Documents folder of my app. I need to present an option that enables users to copy video files from Documents folder to iOS Files app. I also want to automatically have a folder for my app in iOS files app (as seen in the screenshot).

enter image description here

I tried registering Document type "public.movie" (screenshot 2) but didn't help.

enter image description here

Wondering how to achieve it.

Deepak Sharma
  • 5,577
  • 7
  • 55
  • 131
  • 1
    Are you familiar with "LSSupportsOpeningDocumentsInPlace"? I think that, if you add this key to your info plist, then your Documents folder will appear in the Files app. Is this what you wanted? The user can then open the files app and move any video files wherever they want. – DanubePM May 07 '20 at 23:09
  • I think that did the trick, thank you. But I see the files are merely shared and deleting the file from Files app will cause deletion of document from app. Is there a way to do a true copy of files to Files App (although I suspect it isn't possible)? – Deepak Sharma May 10 '20 at 09:37
  • You could create a folder that isn’t in your documents directory (so only visible from your app’s perspective). Then the user could have an option to transfer/copy things to the visible folder. – DanubePM May 11 '20 at 00:47
  • How does one physically copies/transfers file from app to Files? – Deepak Sharma May 11 '20 at 15:04
  • The folder for your app that users see in Files is retrieved like this... `FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)`. I would create a folder anywhere else and use FileManager to copy the files to this folder. Refer to this: https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html – DanubePM May 11 '20 at 22:00
  • I don't know what your app is or what your reasons are, but I suggest that you rethink file copying. Is there a reason you can't just use the Documents folder and skip any copying? You can use the document directory like any other folder. And the user can also see files in this folder and manage the files themselves. You also get the benefit of iCloud backups for this folder. Just something to think about. – DanubePM May 11 '20 at 22:04
  • It looks like Files app has no storage of it's own. It only links to Documents directory of the app. Deleting the app accidentally would cause deletion of all files in Documents directory with way to recover. I thought one could easily copy these to Files app but looks like it is impossible. – Deepak Sharma May 12 '20 at 10:30

0 Answers0