I've built an integration using the Google Docs API (using GData) allowing users to create/edit documents from another application. Originally, when documents were deleted we would have them permanently deleted. They were no longer visible in Google Docs or Google Drive. Now when they are deleted using the Google Docs API, they are still present in the list of Documents in Google Drive. When you attempt to follow the link to the document you arrive at the "Sorry, the page (or document) you have requested does not exist." page.
Does Google Drive not honor the actions taken via the Google Docs API? Do I need to delete these documents using both the Google Docs API and the Google Drive API? What if the user has not migrated to Google Drive? Is there a way to tell if the have migrated? Or do I force them to migrate so I can use the Google Drive API to keep their Google Drive clean of these dead documents?
The Drive API and the Docs List API both operate on the same resources so you only have to use one of them (and we recommend the former).
With the Drive API you can trash or delete files. When you trash a file, it will still be listed in Google Drive with a label to mark it as in trash, so that you can still untrash it.
If you want to remove a file completely, you have to use the delete method.
I was having the same problem and I believe this is some kind of caching on the drive UI.
The file does appear to be deleted correctly and is not visible to the drive API.
The orphaned stubs eventually get deleted as the cache is cleared every so often.
I found that by removing the file from the parent and then deleting it meant that it was easier to see what was going on when using the drive UI whilst testing my app.
service.children().delete(folderId=parent_id, childId=file_id).execute()
service.files().delete(fileId=file_id).execute()
I was facing the same problem while using Google Drive APIs. I think when the Delete api deletes the document, their is still some linking with parent folder remains, so the browser renders the document. when I tired to delete the document with below piece of code, it properly works for me.
DriveService.Childern.Delete(parentResId, fileId).Fetch(); // fileId=>ResourceId of document to be deleted
This is a caching issue, the file has actually been removed. If you try to open the file in the Drive UI you should see something along the lines of "Sorry, the file you have requested does not exist."
It will clear itself soon.
Related
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.
I try to search for files on SharePoint Document Library (e.g. the default 'root'). I created a few test-files by uploading them or create new Office files online and made some search-requests, e.g. https://graph.microsoft.com/v1.0/sites/root/drive/root/search(q='{query}') and until yesterday everything worked fine.
Now I started to edit files on SharePoint or created/uploaded new ones and with this edited or new files, I have the problem that I get no result when I search for them. "old" files, I created when I started I find although, as long as I don't edit them.
To get access I registered an App inside the AAD and gave it the needed permissions (
Sites.Read.All, Sites.ReadWrite.All, Files.Read.All, Files.ReadWrite.All
and a direct access to a specific file with https://graph.microsoft.com/v1.0/sites/root/drive/items/{item-id}/ works also well.
Search will read data from indexed data, but crawling and re-indexing of a library need to take some time. So you the code return null for the new files:
https://graph.microsoft.com/v1.0/sites/root/drive/root/search(q='{query}')
The following code get the library data directly but not based on the indexed data, so it works well.
https://graph.microsoft.com/v1.0/sites/root/drive/items/{item-id}/
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.
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.
I am dealing with mobile and desktop applications. I am trying to use Google Drive as a permanent storage folder. Unfortunately I am at a loss because I cannot find any examples. Can someone point me at an example of storing or retrieving a file from Google Drive?
I would really like to see a simple example in code or maybe a library which can handle this. I am stuck at Retrieve and Use OAuth 2.0 Credentials https://developers.google.com/drive/credentials
Did you look at the sample app on the drive API page?
edit
google moved the examples to github
I don't know if I figured out your problem. What I have understood is that you are looking for a way that makes you able to work on the same project from different computers.
If so, you simply have to download Drive. Once install it will ask you what folder you want to keep syncronized with Drive. If you select your workspace, it will be syncronized with Drive. So, on another pc, if you have installed Drive, you will be able to use the workspace folder too, with the same files.
I hope this is helpful.
Marco
You should look into Documents List API.
The Google Drive API & SDK are meant to be a mean to integrate applications into the Web-UI of Google Drive. To protect the security of the user's files, it puts some restrictions to the application developer, like:
The app has to be installed from the Chrome Web Store
The app can only access files created from the app itself,
or files selected by the user using the Google Picker UI.
All these restrictions make the Google Drive API not a good choice for most non-web applications.
E.g. installing the app from the Chrome Web Store is probably something you would find cumbersome to request from your users for a mobile or desktop application. Nonetheless, without being installed from the Chrome Web Store your application will always receive an error when accessing a file from Google Drive.
The Documents List API allows you to store and load files (not only Google Documents!) into Google Drive.
This question is a little bit old, still. You can look at this example: https://code.google.com/p/google-api-dotnet-client/wiki/OAuth2
They do the OAuth2 for accessing task. But I just used the same code to access the files using the v2 API. http://code.google.com/p/google-api-dotnet-client/wiki/APIs#Drive_API
I only retrieved the file list, but it is working (from .NET, desktop app).