File Provider

RSS for tag

Allow other apps to access the documents and directories stored and managed by your containing app using File Provider.

File Provider Documentation

Pinned Posts

Posts under File Provider tag

88 Posts
Sort by:
Post not yet marked as solved
2 Replies
2.9k Views
I have created working fileprovider, that works perfectly on my local machine. Codesigned in xcode, with our company sign certificate as Developer ID Application. No provisioning profile. Also notarized result dmg. Works as expected on my local machine. But won't load on any other machine. Calling [NSFileProviderManager addDomain: ...], ends up with error: Error Domain=NSFileProviderErrorDomain Code=-2001 "The application cannot be used right now." UserInfo={NSLocalizedDescription=The application cannot be used right now.} Code=-2001 should mean, that no file provider manager extension was found in an app bundle. I have made a TestFileProvider application that is totally simplified File Provider example. This too does work only on my own machine. Relevant code from app: - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { NSFileProviderDomain* fileProviderDomain = [[NSFileProviderDomain alloc] initWithIdentifier:@"com.xxxxx.dwc.FileProvider" displayName:@"TestDomain"]; [NSFileProviderManager addDomain:fileProviderDomain completionHandler:^(NSError * _Nullable error) { if (error) NSLog(@"add domain: %@", error); else NSLog(@"add domain SUCCESS"); }]; } There are also these errors, that are related, but I do not understand what are they implying neither how to fix: kernel Sandbox: fileproviderd(448) deny(1) file-read-data /Applications/TestFileProvider.app fileproviderd [ERROR] PluginRecord doesn't have container url for fileproviderd [WARNING] No provider found with identifier (null) for calling bundle (null) on second attempt. I'm clueless on how to fix this. Is this related to codesign ? Or is it necessary to start fileprovider with different method call ?
Posted
by
Post not yet marked as solved
0 Replies
1.3k Views
General: DevForums tags: Files and Storage, Finder Sync, File Provider, Disk Arbitration, APFS File System Programming Guide On File System Permissions DevForums post File Provider framework Finder Sync framework App Extension Programming Guide > App Extension Types > Finder Sync Disk Arbitration Programming Guide Mass Storage Device Driver Programming Guide Device File Access Guide for Storage Devices Apple File System Guide TN1150 HFS Plus Volume Format Extended Attributes and Zip Archives File system changes introduced in iOS 17 DevForums post Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = "eskimo" + "1" + "@" + "apple.com"
Posted
by
Post not yet marked as solved
1 Replies
1.7k Views
Trying to use file importer in a swift app to upload documents into firebase Storage and getting error when running on live device but works perfectly fine on emulator. error: BackgroundSession <***...> Failed to issue sandbox extension for file file:///private/var/mobile/Library/Mobile%20Documents/comappleCloudDocs/Sample.pdf, errno = [1: Operation not permitted] UNKNOWN ERROR Error Domain=FIRStorageErrorDomain Code=-13000 "An unknown error occurred, please check the server response." UserInfo={object=Repository/Sample.pdf, ResponseBody=Can not finalize upload. Current size is 0. Expected final size is 2665098., bucket=bucket, data={length = 77, bytes = 0x43616e20 6e6f7420 66696e61 6c697a65 ... 32363635 3039382e }, data_content_type=text/plain; charset=utf-8, NSLocalizedDescription=An unknown error occurred, please check the server response., ResponseErrorDomain=com.google.HTTPStatus, ResponseErrorCode=400} I tried separating all the logic from selectedFile.startAccessingSecurityScopedResource() all the way through the end into a function of its own using @MainActor based on another post I found around here and issue persisted.. Below is the implementation: .fileImporter( isPresented: $fileImporterIsPresented, allowedContentTypes: [.pdf], allowsMultipleSelection: false ) { result in switch result { case .success(let url): print(url) guard let selectedFile:URL = url.first else { return } guard selectedFile.startAccessingSecurityScopedResource() else { return } let firebaseRepository = Storage.storage().reference().child("Repository/Sample.pdf") let uploadTask = firebaseRepository.putFile(from: selectedFile) uploadTask.observe(.progress) { snapshot in // Upload reported progress percentComplete = 100.0 * Double(snapshot.progress!.completedUnitCount) / Double(snapshot.progress!.totalUnitCount) } uploadTask.observe(.success) { snapshot in selectedFile.stopAccessingSecurityScopedResource() uploadTask.removeAllObservers() print("SUCCESS") // Upload completed successfully } uploadTask.observe(.failure) { snapshot in if let error = snapshot.error as? NSError { switch (StorageErrorCode(rawValue: error.code)!) { case .objectNotFound: print("NOT FOUND") // File doesn't exist break case .unauthorized: print("UNAUTHORIZED") // User doesn't have permission to access file break case .cancelled: print("CANCELLED") // User canceled the upload break /* ... */ case .unknown: print("UNKNOWN ERROR \(error.description)") print("UNKNOWN ERROR \(error.localizedDescription)") print("UNKNOWN ERROR \(error.underlyingErrors)") // Unknown error occurred, inspect the server response break default: print("UNSPECIFIED ERROR") // A separate error occurred. This is a good place to retry the upload. break } } } case .failure(let error): print(error) } }
Posted
by
Post marked as solved
3 Replies
1.5k Views
The existing project of Finder Extension is doing an amazing job in other paths but when I point it to the CloudStorage path the context menu doesn't show up. And no trace of what is going wrong any where (Xcode Logs, Console log, crash log, etc.) Path Used: /Users/<User>/Library/CloudStorage/FP-SomeDomains Yes, even my first though was, it must be because of dataless file and folders. But unfortunately it not. There was no context menu presented from my Finder Extension even on real physical files and folders.
Posted
by
Post marked as solved
6 Replies
2.6k Views
I have a FileProvider app consisting of MainApp and FileProviderExtension. MainApp has a popover which should have features like: Button which opens FileProvider folder List of files being uploaded/download and when user clicks on a file, it should either be opened or shown in Finder in containing folder. How to achieve these in Sandboxed macOS app? I know it's possible because Microsoft's OneDrive app is distributed via AppStore and can perform these features. So far I've been able to create an alias to a FileProvider folder in user's home folder by utilizing NSOpenPanel. I tried opening FileProvider files from MainApp with something like: let url = try! await NSFileProviderManager(for: myDomain)?.getUserVisibleURL(for: fileIdentifier) NSWorkspace.shared.open(url!) but getUserVisibleURL returns nil. Does anyone know how to achieve described functionality?
Posted
by
Post not yet marked as solved
1 Replies
1.2k Views
This seems to be a bug in the macOS FileProvider framework. Repro steps: Open a file in the File Provider domain and edit it using WPS Office Save the file in WPS and close the editor tab or WPS Office window The file in the File Provider domain shows an uploading icon, and the modifyItem(_:baseVersion:changedFields:contents:options:request:completionHandler:) callback will never be triggered, so the file won’t be uploaded, and will always shows an "uploading" icon I investigated the issue and found out that the root cause seems to be related to flock, In step 2, after saving the changes, the file is still exclusively locked by WPS Office, In the log of fileproviderd there is an error saying "itemIsFlockedCanNotPropagate", this is understandable since the file is exclusively flocked, and fileproviderd couldn’t propagate the item and trigger the modifyItem callback, What I'm struggling with is that after the file is closed, or even after the WPS Office app has been quit, the modifyItem callback still won’t be fired by the system. What’s even more interesting is that at this time if you manually invoke flock(fd, LOCK_UN) for the file, the modifyItem callback will be triggered right away. In other words, it seems to me that fileproviderd is monitoring the unlock signal of the file descriptor, if a file is flocked with flock(fd, LOCK_EX) and then closed without invoking flock(fd, LOCK_UN), fileproviderd will not able to propagate the change and the modifyItem callback will never be triggered, then FileProviderExtension or the App won’t know that file is changed, the file will always shows an “uploading” icon in Finder. I've tested this against the official FruitBusket sample, OneDrive, Box-Drive and Dropxbox, they all implemented the NSFileProviderReplicatedExtension, and all have the same issue.
Posted
by
Post marked as solved
1 Replies
857 Views
I have an app with two targets: MainApp FileProvider Extension I would like to be able to open the FileProvider CloudStorage folder in Finder from within the MainApp. So far, I've only be able to achieve that by asking user to select his Home folder via NSOpenPanel, and then persisting security-scoped bookmark data, create symbolicLink in user's home folder and then later in the app: let aliasLocationURL = try URL(resolvingBookmarkData: aliasLocationBookmarkData,                             options: .withSecurityScope,                             relativeTo: nil, bookmarkDataIsStale: &isStale) aliasLocationURL.startAccessingSecurityScopedResource() NSWorkspace.shared.open(aliasURL) aliasLocationURL.stopAccessingSecurityScopedResource() The problem is that if user does not select his Home folder via NSOpenPanel then my app gets an error message: The application “MyApp” does not have permission to open “MyApp-FileProvider.” I can get the path to CloudStorage folder via: let fileProviderFolderURL = try await NSFileProviderManager(for: domain)?.getUserVisibleURL(for: .rootContainer) and it properly states that fileProviderFolderURL is /Users/me/Library/CloudStorage/MyApp-FileProvider but whenever I try to open that path, it results in error.
Posted
by
Post not yet marked as solved
2 Replies
1.3k Views
My project has a base app which is manually signed, inside I have a FileProvider parent app and extension. When things works elegantly in Xcode debug build when I run FP App. But, when I package it, the FileProvider can't mount, fails with a generic error on parent app (Error Domain=NSFileProviderErrorDomain Code=-2001 "The application cannot be used right now." UserInfo={NSLocalizedDescription=The application cannot be used right now.} Another generic error in FileProvider demon fileproviderd(488) deny(1) file-read-data /Applications/XYZ.app/Contents/Resources/FileFP.app How to solve this?
Posted
by
Post not yet marked as solved
2 Replies
952 Views
I am building a document-based app with SwiftUI, but whenever I want to create a document in the app, the app shows an alert with the following title: "The document could not be opened" I hit the same problem with Apple's sample project: https://developer.apple.com/documentation/swiftui/building_a_document-based_app_with_swiftui The interesting part is that I only get this error message when I am creating a new file from the "Recents" tab, but when I am creating it from the "Browse" tab, then it works. The beta testers from my app are also experiencing this issue, and they use multiple types of OS versions, and they have enough storage to create the files.
Posted
by
Post not yet marked as solved
2 Replies
1.1k Views
I'm building a file provider extension and running into an issue I don't understand and am not sure how to resolve. I have been building the extension for a while and testing various things, and one of the biggest problems has been reliability. The current problem I'm running into is that when I build a new version of the process that contains the extension in Xcode, I get the error mentioned in the title when I try to register a domain (and the extension does not run). There's not much information I can find about what this error means or how to deal with it. I cannot find any running processes associated with my host application or the extension's name or id (though I may not have looked in the right places). Restarting the computer doesn't seem to resolve the issue either. Any ideas? (As an aside, at various points things have seemed to work just fine for me and even in a VM and then failed to work on other people's machines with no easily discernible reason, so any suggestions about ways to debug file provider issues are welcome)
Posted
by
Post marked as solved
1 Replies
870 Views
Hi, So I am bundling a FileProvider Extension with my electron application and have noticed a very strange behavior. When I package my application and install/launch it from any directory everything runs perfect. However the exception is when I install it to/launch it from the /Applications folder. Specifically I receive Cannot create domain: Error Domain=NSFileProviderErrorDomain Code=-2001 "The application cannot be used right now." which maps to providerNotFound. Seems that the provider is failing to instantiate altogether, and therefore I lack any extension functionality. After I have run the app from the /Applications folder once if I try and run the app from any other directory it fails and I get the same error message. Anybody have any clues as to what may be changing in my environment that driving this behavior?
Posted
by
Post not yet marked as solved
1 Replies
795 Views
Hello, I am trying to add thumbnails to a replicated file provider extensions but the fetchThumbnails method never gets called. After adding the NSFileProviderThumbnailing protocol and fetchThumbnails method to my class I can see the change in behaviour in Finder when I click on a non materialised item as it displayed an empty space instead of the generic file type icon when the protocol is not added. I noticed the mention of caching based on itemVersion but I would still expect the fetchThumbnails method to be called for all newly enumerated items when Finder is in thumbnail mode ? Thanks,
Posted
by
Post not yet marked as solved
0 Replies
545 Views
I added thumbnail fetching to my file provider and it now works great for files that are previewed by Finder / QuickLook like png, jpeg, tiff, ... The system I am connecting to also handles thumbnailing for file format like Adobe Indesign / Illustrator but the file provider doesn't seem to call fetchThumbnail for those types of files and keep the system default generic icon. How can I force fetching thumbnails for those types of files on the file provider file-system ? Thanks,
Posted
by
Post not yet marked as solved
2 Replies
825 Views
I have a Login Item that is bundled with my .app and can run in the background. The Login Item has a File Provider extension. When a user downloads and installs a new version of the main .app, what's the correct way to handle stopping and restarting the login item and File Provider related processes to make sure they are running the latest code also?
Posted
by
Post not yet marked as solved
0 Replies
799 Views
We've written a FileProvider plugin which displays the decrypted versions of encrypted files and folders stored in Dropbox. When removing encryption from a folder, we found one file was not properly decrypted -- it remained under its encrypted name (bPw4vCA6j5LOU,QuABQSsgmC.empfs). This turned out to be the folder's .DS_Store file. For some reason, a standard C++ iteration of the FileProvider folder did not include it. Is this normal behaviour for FileProvider? For the record, the problem doesn't occur if we iterate a non-FileProvider directory on the filesystem (e.g. "/Users/orextest3/Dropbox/EMPSecureFolders/EncryptedOrexTest3/"), only if we iterate the FileProvider mounted folder ("/Users/orextest3/Library/CloudStorage/EMPSecure-EMPSecureDropbox/EMPSecureFolders/EncryptedOrexTest3/"). And in some cases, the problem doesn't occur (I suspect a Finder setting of some sort). How can I ensure that these hidden files are included in an iteration? For the record, the C++ iterator loop was implemented using boost::filesystem: for (directory_iterator itr(source); itr!=directory_iterator(); ++itr)
Posted
by
Post not yet marked as solved
2 Replies
568 Views
I need to prevent folder-creation in certain scenarios. I know I can achieve that via NSFileProviderUserInteractions but that only works when folder creation attempt is done via Finder. If however, user tries to create a folder in Terminal via mkdir folder1 then createItem callback does get called. In createItem callback I tried two options: Option 1 func createItem(basedOn itemTemplate: NSFileProviderItem, fields: NSFileProviderItemFields, contents url: URL?, options: NSFileProviderCreateItemOptions = [], request: NSFileProviderRequest, completionHandler: @escaping (NSFileProviderItem?, NSFileProviderItemFields, Bool, Error?) -> Void) -> Progress { let progress = Progress(totalUnitCount: 1) if itemTemplate.parentItemIdentifier == .rootContainer || itemTemplate.contentType == .aliasFile || itemTemplate.contentType == .symbolicLink { print("Preventing item creation in root level") let entry = Entry( id: UUID().uuidString.lowercased(), type: itemTemplate.contentType == .folder ? Entry.Kind.folder : Entry.Kind.file, filename: itemTemplate.filename, parentId: NSFileProviderItemIdentifier.trashContainer.rawValue, contentType: itemTemplate.contentType!, size: itemTemplate.documentSize as! Int, creationDate: itemTemplate.creationDate!!, modificationDate: itemTemplate.contentModificationDate as? Date, lastUsedDate: itemTemplate.lastUsedDate as? Date, fileSystemFlags: itemTemplate.fileSystemFlags?.rawValue ?? 4, version: nil, rootContainerId: nil, archived: false ) let item = FileProviderItem(entry: entry) print("Returning trashed item") completionHandler(item, [], false, nil) return progress } // other code } and indeed when creating folder via Finder (with NSFileProviderUserInteractions disabled), folder appears briefly and disappears immediatelly after that. Option 2 func createItem(basedOn itemTemplate: NSFileProviderItem, fields: NSFileProviderItemFields, contents url: URL?, options: NSFileProviderCreateItemOptions = [], request: NSFileProviderRequest, completionHandler: @escaping (NSFileProviderItem?, NSFileProviderItemFields, Bool, Error?) -> Void) -> Progress { let progress = Progress(totalUnitCount: 1) if itemTemplate.parentItemIdentifier == .rootContainer || itemTemplate.contentType == .aliasFile || itemTemplate.contentType == .symbolicLink { print("Preventing item creation at root level") let error = NSError( domain: NSCocoaErrorDomain, code: NSFeatureUnsupportedError, userInfo: [ NSLocalizedDescriptionKey: "Folder creation is not allowed." ] ) completionHandler(nil, [], false, error) return progress } // other code } The problem is that with both options, when folder is created via Terminal, it stays created. Extension marks the folder with exclamation-mark and attempts to invoke createItem callback a few times before giving up. My goal is to prevent folder-creation in the first place so that when user tries to create folder in Terminal, he can get an error in respond. % mkdir folder1 error: folder creation forbidden Is that possible to achieve with FileProviderExtension?
Posted
by
Post not yet marked as solved
0 Replies
467 Views
below is the scenario... I've created a local server that'll serve me files from the system which is encrypted by a key. When i try to read the File from the server , it'll decrypt and open the file. This all is working fine in other OS systems like Windows and archLinux using Fuse and similar alternatives. Now when I'm implementing the same in macOS using File Provider. I found out that Its making a local copy which is decrypted and then opening the file (fetchContents()). This is basically breaking the whole point of the project. Is there a way to not download this file and Open directly from memory instead ? (apologies if the issue was not explained correctly or was not worth mentioning, I'm still new to macOS development)
Posted
by
Post not yet marked as solved
1 Replies
415 Views
I'm implementing FileProviderExtension on macOS (NSFileProviderReplicatedExtension) and one requirement I have to support is the support for locked files. My requirement is that writing to locked files should be forbidden. Is there a way to support that in FileProviderExtension? My approach was to report capabilities in FileProviderItem like: var capabilities: NSFileProviderItemCapabilities { if locked { return [.allowsReading, .allowsReparenting, .allowsDeleting] } return [.allowsReading, .allowsWriting, .allowsRenaming, .allowsReparenting, .allowsDeleting] } and indeed rename is forbidden (in Finder you cannot enter rename-state) but writing to file is allowed. Is there a way to prevent writing to file in macOS FileProviderExtension?
Posted
by
Post marked as solved
1 Replies
693 Views
I've been building a finder extension for managing a bunch of videos in a remote server. When I try to click on a video file that is dataless it seems to always trigger fetchContents(for:version:request:completionHandler:). I have implemented fetchPartialContents(for:version:request:minimalRange:aligningTo:options:completionHandler:) but i haven't been able to trigger this method no matter how large the size of the file is. What are the conditions that i have to meet to trigger this function so i could stream the video data in chunks ?
Posted
by
Post not yet marked as solved
0 Replies
504 Views
I need to correctly determine the mime type of keynote file and numbers file without relying on the extension. For this purpose, I am hoping to use the magic number concept and match it with the first four bytes of a file. Link for magic number understanding -> [https://www.outsystems.com/forge/component-overview/10108/validate-file-extension#:~:text=A%20magic%20number%20is%20a,types%20which%20is%20hexadecimal%20format.] Though after extensive searching online I am unable to find a unique magic number for the above files moreover first four bytes of the file is matching with the magic number of the zip file due to which I am getting the wrong extension as zip. This is the first four bytes 0x50, 0x4B, 0x3, 0x4. Is there any reliable way to find the mime type of these files without relying on an extension?
Posted
by