google drive folder information - google-drive-api

I would like to use Google Drive to push files in various folders onto a remote computer. I would like this to be a one-way transaction so the people using the computer cannot write to Google Drive.
However, when I use the following C# code to get the files from Google Docs I only get the file names, not their directories where they will be on the remote computer. This won't work because some files in different directories have the same name. Is there a way to programmatically get directory information from these files?
Alternately, if I could set up the Google Drive folder to be read-only, that would accomplish my goal and probably be easier. Can this be done?

You should use the Google Drive API to list all files and check the parents field of each of them to map those files into folders:
https://developers.google.com/drive/v2/reference/files#resource

Related

Is it possible to upload an entire folder to Google Drive using Google Drive API?

I am currently exploring Google Drive APIs and am able to upload an individual file using Postman successfully.
I tried to create/upload a folder using Google Drive API but failed. In fact, I don't see any specific API to deal with a folder. I was giving it a try with create files API.
Reference - https://developers.google.com/drive/api/v3/reference
Any help will be appreciated.
If you check the documentation for files.create you will notice at the top it states
Creates a file.
This is singular each request creates a single file. If you want to upload a directory you will need to first create the directory then upload each file one at a time.
You could try batching but I don't think you can batch the file upload itself you could probably batch the metadata creation performance#details

API Changes for Google Drive’s folder structure and sharing models

I used to use below Google Drive API to move my existing file to another drive folder
drive.files().update(fileId=cloudFile['id'],addParents=sharefile,media_body=media).execute()
I just got an email said that the Google Drive folder structure is changed and I'm not allowed to use "addParent" to share filers anymore. I was wondering how can I do this with drive API? I don't want to re-write the entire code, and I'm looking for the simplest way to replace addParents API.
Answer:
Instead of giving a file multiple parents, you can create a shortcut to another Drive file instead (such as a folder).
More Information:
You can use the shortcuts functionality of Google Drive instead of the multiple parents functionality to emulate the kind of behaviour. From the Documentation:
Shortcuts are files that link to other files on Google Drive.
Shortcuts are Drive files with the application/vnd.google-apps.shortcut MIME type, that point to another file or folder on a Google Drive. You can read more about this here.
References:
Create a Shortcut to a Drive File
Find files & folders with Google Drive shortcuts
G Suite and Drive MIME Types

Browse Files and folders uploaded on Google Drive

I'm writing from Italy (sorry for mistakes), my question is about GOOGLE DRIVE API and
I'm writing here because the G-Suite support wrote me to contact you, I'm not a programmer.
The big question is: how can I browse folders and files uploaded on my Google Drive Api?
I write you what apppened.
I wanted to use a backup program to save in a planned way files and folders an Google Drive.
I downloaded the program (Iperius Backup) and followed the instructions.
To understand on what I did, I paste the link of the instructions below:
http://www.iperiusbackup.net/en/backup-to-google-drive/
http://www.iperiusbackup.net/en/how-to-enable-google-drive-api-and-get-client-credentials/
I tried the software and everything worked.
So I opened Google Drive but the back-upped files weren't there.
Seen that there was something not clear, I have erased all the files on my Google Drive. I wanted to make sure that it was empty, hoping to erase also “hidden files”(...even if I thought it wouldn't have been so simple...)
To make sure that everything was erased (also “hidden files”), I tried to restore files from the backup software but unfortunately, the software worked well...the files were still there, somewhere...
This means that I have saved through the backup software files and folders on Google Drive “Api”, but I cannot manage them.
How can I have access to my space in Google Drive Api and erase all my files and folders that are still there?
Thank you in advance for the help,
best regards,
Stefano
To list all files in your drive, you can use Files: list.
This method accepts the q parameter, which is a search query
combining one or more search terms. For more information, see the
Search for Files and Team Drives guide.
You can use the Try it now or use the sample code given in a specific language you are using.
To delete/erase a file, use Files: delete.
Permanently deletes a file by ID. Skips the trash. The currently
authenticated user must own the file or be an organizer on the parent
for Team Drive files. Try it now or see an example.

How does google Drive fetch all containing files of folder while we upload folder?

I noticed that while upload any folder on Google drive, Its automatically listed all containing files from an specific folder, however its all at client end and as per my knowledge no any client end language access client directory or system details then how Google Drive listed all containing files by giving only folder reference.
I am not sure about the exact implementation for Google Drive folder upload, but in HTML5, there is a webkitdirectory which support the operation.
See: http://earlysandwich.com/programming/how-to-upload-multiple-files-or-folders-with-html-and-php-168

Move file from appDataFolder to user's root folder with Google drive API

Is it possible to move file from appDataFolder to user's root folder on Google Drive using drive API v2 or v3? I can't find any example how to do that. I just try to use gapi.client.drive.files.update from javascript drive v3 API and addParents parameter to change folder, it works fine with files in user's root folder, but doesn't work with files in appDataFolder.
I know that it is possible to copy file from appDataFolder to user's drive root, but I need to keep fileId, and copying generates new fileId for copied file.
I found there is a file property called "spaces" and files from appDataFolder a in spaces=appDataFolder whereas files from user's root folder are in spaces=drive. Is it possible to move file between these spaces keeping same fileId?
I found some similar posts:
Copy an exising Drive file into the appdata folder
Is it possible to share the application data on google drive
and it looks like it is not possible to do it this way. When I check my console I also get "Method not supported for appdata contents" or "Method not supported for files within the Application Data folder." message.
So is there any method to move file from appDataFolder?
Thank's for help.
No, it seems to be impossible. The current document doesn't mention about that, but the error message clearly says so. Thumb down for drive api.