Swift ghost files

Discussion in 'Mac Programming' started by Tanax, May 25, 2017.

  1. Tanax macrumors 6502a

    Joined:
    Jun 15, 2011
    Location:
    Stockholm, Sweden
    #1
    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.
     
  2. Starfia macrumors 6502

    Starfia

    Joined:
    Apr 11, 2011
    #2
    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.
     
  3. Tanax thread starter macrumors 6502a

    Joined:
    Jun 15, 2011
    Location:
    Stockholm, Sweden
    #3
    Thank you.
    Does that work for non-iCloud stored files? Remember, this is fetching from NAS or other remote FTP location :)
     
  4. Starfia macrumors 6502

    Starfia

    Joined:
    Apr 11, 2011
    #4
    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.
     
  5. Tanax thread starter macrumors 6502a

    Joined:
    Jun 15, 2011
    Location:
    Stockholm, Sweden
    #5
    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?
     
  6. 960design macrumors 68020

    Joined:
    Apr 17, 2012
    Location:
    Destin, FL
    #6
    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.
     
  7. Tanax thread starter macrumors 6502a

    Joined:
    Jun 15, 2011
    Location:
    Stockholm, Sweden
    #7
    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?
     

Share This Page