Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Tanax

macrumors 65816
Original poster
Jun 15, 2011
1,039
409
Stockholm, Sweden
Hi!

I'm curious to know how you can create ghost files with Swift?

Example being an app that performs a request to your NAS, e.g., and renders the files it gets in the response as 0 KB files in a specific folder, perhaps the thumbnail should work but still not taking up a lot of space. Opening the file will of course download the entire file from the NAS.

Is this possible?
I've looking into FUSE but not sure it suits my needs nor if there's an implementation for Swift.
 
I'm not sure if this is exactly what you mean, but it sounds like you're describing iCloud document storage (see the iCloud Design Guide) – at least, if you're using iCloud as a registered developer. You request metadata to get a lightweight picture of all remotely-stored files before downloading any explicitly. The UIDocument class includes some built-in support for this.
 
I'm not sure if this is exactly what you mean, but it sounds like you're describing iCloud document storage (see the iCloud Design Guide) – at least, if you're using iCloud as a registered developer. You request metadata to get a lightweight picture of all remotely-stored files before downloading any explicitly. The UIDocument class includes some built-in support for this.

Thank you.
Does that work for non-iCloud stored files? Remember, this is fetching from NAS or other remote FTP location :)
 
I think the APIs you use to deal with them – whether automatically with UIDocument or directly with NSFileManager – are integrated directly with iCloud. (So, you have to use files the user has put there.) There are other iCloud services available that deal with interaction with your own servers, but I've never waded deep enough into it to know whether it's what you're after; I think they refer to that as CloudKit.

I haven't done much with using native apps to fetch files from arbitrary servers beyond that; I'd imagine you'd have to have some way to poll the server for a directory's contents and then roll your own interface for representing available files that had not downloaded.
 
  • Like
Reactions: Tanax
As an example of this functionality, look at Dropbox's "Smart Sync": https://www.dropbox.com/business/smartsync
How do they do that? Render the files even though the content of the files are not fully loaded but instead stored in Dropbox cloud?
I would add a database table with file type and name to the file database. Build a rest API that accesses this table to display the folders and file names. When someone tapped on a file I would fetch it from the API. I'd display a little cloud with the download arrow to let the user know the file is not actually on the device.
 
I would add a database table with file type and name to the file database. Build a rest API that accesses this table to display the folders and file names. When someone tapped on a file I would fetch it from the API. I'd display a little cloud with the download arrow to let the user know the file is not actually on the device.

Yes, that's how I would also do it.
However, how do you actually display that file in Finder? Is it an empty file of the same file-type as the real file with a listener on it so that when user opens it, it can go ahead and download the rest of the file content? Or how is that done?
 
Anyone? :)
How do you create an empty file that looks like a real file like Dropbox's "Smart Sync"?
Ideally with a functional thumbnail? Is that even possible in Swift?

Dropbox built their own kernel extension to handle a virtual file system, much like FUSE. I would like to avoid that, don't want to mess with kernel.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.