Keeping GoogleDrive files in sync with local files - ios

I'm integrating Google Drive into an iOS app with the SDK, (which works great, thank you) and I would like to keep a set of files on Google Drive in sync with files on the device. By this I mean: When a user renames or moves a file on their device, I'd like it to rename/move on the server. If a user renames a folder, I'd like to rename that folder on the server.
With other cloud services that use a path to identify files, I can generate the path to rename or move the files on the server whenever I need them. With Google Drive, this is not the case--I need a file ID to rename or move something. Is there a convenient way to get the file ID from a path? Will I have to store information from Google Drive in my app? Is there a recommended best practice for this situation? Thanks for any help!

As far as I can see, you can keep a list of file ID when initially you insert file into Google Drive. When you insert a file into Google Drive, it will return a file resource which contains the inserted file ID and it doesnt change unless you delete it.

Related

Hyperlink to a file in the current folder regardless of its location on the drive

Putting together a .doc file with a table of content with links to external files. The challenge is: how to make them so that it points to the given file in the current folder regardless of its location on the disk.
Context: I will be sending the set of files to another person, so I can't put the path on my machine, nor on a server since they will be working offline. They will be working on Remarkable device and I want them to be able to use the major overview file with the links to access each of the files, rather than having to browse the folders.

Find Deleted File in an AppFolder

How do I find a file that was deleted and had a relative path of /foo/baz.txt?
I am using the /v1.0 endpoint and my app requests the Files.ReadWrite.AppFolder scope. I can access /drive/special/appRoot.
Will /drive/special/appRoot:/search(q='baz.txt') find deleted files?
Will /drive/special/appRoot:/foo/baz.txt:/versionsversions for a deleted file?
There is not a lot of examples (or documentation support) for using AppFolder.
I'm afraid this isn't possible today.
When a file is deleted from OneDrive (either via the Web App or the API), it is sent to the Recycle Bin and held for 30 days (assuming the user doesn't manually empty it of course).
At the moment, it isn't possible to access or restore a DriveItem from a dive's Recycle Bin (this has been discussed but I'm unaware of any ETA). The only way to restore an item today is for the user to do so via the OneDrive Web App.
According to your description, I suppose you want to get a file that was deleted in App Folder.
Based on my test, we can use the following API to get the file in App Folder:
/drive/special/approot:/foo/baz.txt:/
However, if we deleted the file, it will return a 404 status code when we use this API.
We can get the file by using this API unless we restore it in the Recycle bin of OneDrive.

Is it possible to gain forever access to a file imported from DocumentPicker?

I have an app that imports a file (or many files) using the DocumentPickerDelegate. This means that the files imported are likely off of iCloud, Google Drive, etc. I want the app to load any previously selected files on startup, but I'm wondering if this will be possible, since it looks like you lose access to the files once the app closes.
Does anyone know a way around this? For example, are you able to actually copy the imported files to the apps local data?
Thanks for your help!
In the delegate where it gives you the URLs of the selected files you need to make local copies of the files before the delegatecall completes. This is covered in the documentation for UIDocumentPickerController.

Send Excel files to Office for editing and read changes

Right now I have an Excel file locally in my iOS application and the file is downloaded from our own servers.
I want to be able to edit the Excel file somehow and I can't seem to get my head around how to do it with the Excel app.
I'm aware that you can't edit local files in another app like that, so I tried with links to files on my OneDrive account. I just can't seem to get the url right.
It seems like I need a direct link to the file, but all I get is a guest access link, when I make the file shareable.
Have you tried the Google Sheets app? Might do the trick.

How secure is the iPhone's temporary file directory?

On my app (swift 2.3, xcode 7+, for iOS 9+) I'm write to a file, use the file, and then delete the file from a tmp directory created with NSTemporaryDirectory (on the app sandboxed). Although its a quick automated sequence, for a brief moment the file is written to the tmp directory in order to be used and then deleted.
My concern is: How secure, for that brief moment, is the file stored at tmp directory? Could an attacker get access to the file at the moment it's on the tmp directory?
If you're writing a file just to delete it, you should try to avoid storing the file on the system altogether. If you absolutely have to store the data on the device, you can use the .completeFileProtection option.
According to the documentation, .completeFileProtection will make it so the file is accessible only when the device is unlocked. This means that the only way that someone would have access to your data is if they have your phone's password, are somehow able to remotely unlock it using said password, and then execute code that has access to your app's sandboxed temporary file storage.
As far as I know, this would be very hard to achieve.

Resources