Explore shared folders and get global informations - api

I want to make a program with the google drive API.
But I am not sure if this is possible. I want to make a program who explores my shared folders. Go into the last folder, give me all global information (date/owner/what inside/size of the folder/if he got folders in him). And after coming back in, "his father folder" and continue to give me the same information.
BUT ! If the "father folder" has a second child, he gives me the second child information first.
I just want to know if this is possible and if is not too complicated( I an not an expert).
Thanks for your help.

Hello every action ou described is possible !
Have a look at https://developers.google.com/drive/v3/reference/
You can list, filter, get informations on files and folders delete, share, insert
Good luck

You have to use sharedWithMe, when using the Querying for Files:
The "Shared with me" category includes files owned and shared by others users which have been either: directly shared with the current user, a group containing the current user, or have been accessed by the current user.
Here is sample snippet that search for files shared with the authorized user with "hello" in the name:
sharedWithMe and name contains 'hello'
For "Go into the last folder, give me all global information (date/owner/what inside/size of the folder/if he got folders in him). And after coming back in, "his father folder" and continue to give me the same information. BUT ! If the "father folder" has a second child, he gives me the second child information first."
This will depend on your implementation but you have to recursively get the children of a folder type file. As stated in this related SO post,"stop thinking about Drive as being a tree structure. It isn't. "Folders" are simply labels, eg. a file can have multiple parents."
After getting the desire fileID with your specific qualifications, get the details using file.get or include the details you want to get in file.list.
Hope this helps.

Related

How to get MS Teams' channel files and folders

I'm working on an API and i want to get Files and Folders of a specific teams' channel. I've tried with Graph Explorer but could not find anything resource. I have also tried the official documentation Microsoft Graph API.
I have tried the following API in explorer but it does not give the desired results.
https://graph.microsoft.com/v1.0/teams/{teamId}/channels/{channelId}/filesFolder
It is highly possible that i might have overlooked the my required resource but can someone help me out in it. Thanks
You are using the correct endpoint
GET https://graph.microsoft.com/v1.0/teams/{team_id}/channels/{channel_id}/filesFolder
returns metadata about driveItem.
Use parentReference.driveId and id in the next API call to get folders and files
GET https://graph.microsoft.com/v1.0/drives/{drive_id}/items/{id}/children
It returns a collection of driveItems with unique id.
If driveItem represents a file then file property is not null.
For each item that represents the file you can call
GET https://graph.microsoft.com/v1.0/drives/{drive_id}/items/{item_id}
to get more details about the file.
If driveItem represents a folder then folder property is not null.
For each item that represents the folder you can call
GET https://graph.microsoft.com/v1.0/drives/{drive_id}/items/{item_id}
GET https://graph.microsoft.com/v1.0/drives/{drive_id}/items/{item_id}/children
to get more details about the folder or to get items inside the folder.

Nextcloud: Groupfolder OCC for advanced permissions

I would like to implement the following:
I have a "master folder" in which all subfolders are structured down. However, these subfolders are person-related and should only be visible and editable for the authorized persons including the admin -> This also means that those who do not have authorization should not even see the folder.
I was able to implement the whole thing very successfully, without problems, but with a lot of click work on the web interface.
Now I want to automate the whole thing:
create a user in Nextcloud
create a personal subfolder in the "master folder"
assign authorization
The first point has already worked without problems -> the new user is created correctly and added to the group accordingly.
The second point also worked, but I create the folders via mkdir and then execute the command occ files:scan --all. The folder is already visible for all in the "Master Folder".
Now we come to the third and last point:
I absolutely can't figure out how to create the appropriate Manage advanced permissions on command line level.
The whole group should not be able to see the folder, except the selected persons. I can't find any commands to do this without using the web interface...
I really hope that you can help me somehow, otherwise I will soon be busy with clicking only ...
I'm not 100% sure what you try to achieve here, so here are a few answers that I can think of right now:
Have new users have the same files
If your goal is to have every new user have the same files in their folder, you can just change the files in /core/skeleton. When a user is created, these files are copied into their home.
If the files change a lot you can just upload them to your admin account an share them with the group everyone. (Need the app Everyone Group for that) The users then will see the files shared with them in their homedir.
Have one folder where all users can read everything, but only write to their own folder
For this I would do the following to set it up:
Go to Settings > Group Folders
Add a group folder (let's call it master here)
Give the groups everyone and admin permissions to read and write
Activate special permissions and give them to the admin group.
Go to Files and enter the new group folder master
Click on the 'share' Symbol in the top next to the folder name
In the right hand panel, go to the share tab
At the bottom make sure that:
Admin has permissions to read/write/delete everything
Everyone only has permissions to read files and is denied everything else
These permissions are set without inheritance. (The arrow are a bit grey when inherited and full black when not)
Now you can do the following every time a user is created:
Create a folder in master (either as you suggested or sync an empty folder via nextcloudcmd)
Use the occ groupfolders:permissions command to set the permissions. See here for more information
The command probably will look something like this:
occ groupfolders:permissions <folder_id> --user=<username> <path> -- +read +write +create +delete
So if master has the folder_id 1, the user has the user_id adam and you named this folder adams_dir:
occ groupfolders:permissions 1 --user=adam /adams_dir -- +read +write +create +delete +share
I hope this is what you are looking for.
Required Apps to be installed:
Group Folders
Everyone Group

Can I get children using folder name and id in the same time using Microsoft Graph API?

I am trying to display folder and file list from a Sharepoint in my CakePHP web application.
Please review my previous question here.
What I am going to do is to get children from a folder with id and also inner folder with name, in the same time, using Graph API.
I want to get list from an api like
https://graph.microsoft.com/v1.0/drives/{drive-id}/root:/{folder-name}:/items/{item-id}/children
I am not sure if it is available and how to implement it.
At this moment, I can get children from a folder with its name.
https://graph.microsoft.com/v1.0/drives/{drive-id}/root:/{folder-name}:/children
And I can filter the response using query parameters like below.
https://graph.microsoft.com/v1.0/drives/{drive-id}/root:/{folder-name}:/children/?$filter=id eq '{folder-id}'
Can I get sub folder's children at this moment?
Any help?
There is no such method. As #Shiva said, their properties are the same. You cannot use the folder name and folder ID at the same time. You can try the api provided by Shiva. I think it is a good method:
https://graph.microsoft.com/v1.0/me/drive/root:/{folder-name}?$expand=children

Using the Quip API, how can you get a list of all threads?

I need to get a list of all publicly-visible Quip documents in my company using the Quip API. I have a service worker account that will make the API calls.
My question: how do I find the root folder to start from?
Quip's API docs tell you how to get info about one or more folders using Get Folders by passing in the folder ids. You can call this again for nested folders, and you can call Get Threads to get information about each document. (Quip uses the terminology "threads," not "documents.")
But where do I start? I need a root folder to start recursing from, right.
Here's what I've tried:
The Get Folders docs say "To find your desktop or archive folder ID, see Get Authenticated User." I've tried that but it returns folders called Desktop, Archive, Starred, Private, Shared, and Group.
Desktop seemed like a good place to start but its only child is Archive, and...
Archive only contains a couple dozen docs. The meaning of the Archive folder is not documented.
Starred is docs you've favorited.
Private is your private docs.
Shared is docs that have been shared with you.
Group seemed promising because the Folders UI at quip.com/browse shows the word "Group Folders" at the top. But my account's Group Folder list is empty.
A bit late to this, but since the QUIP API is poorly maintained and not well documented, for those looking to solve the same problem, here is one way:
Step 1: Add your company's root folder to your favorite (Starred folder), and drag it to the top of the favorite list.
Step 2: Get you authenticated instance:
quip_client = quip.QuipClient(access_token=login_token)
user = quip_client.get_authenticated_user()
print (user)
You will retrieve a json result with basic information like name, id... and most importantly the starred_folder_id for the user.
Step 3: Pass the starred_folder_id to the get_folder method:
print (quip_client.get_folder("starred_folder_id"))
You will receive yet another json with a key named as children which contains values of your starred folders/files in the order it appears on your quip app. The first folder_id will be your company folder id.
You can now use the folder_id to retrieve the rest of your company documents by more get_folder.

Opening a file using Sandbox

OK, so I know that under the new SandBox guidelines, opening a file must abide by certain rules (a.k.a. the opening action must be triggered by the user using an NSOpenPanel, given of course the necessary "open" permissions).
However, here's the catch :
In my application, I've got an NSOutlineView with a complete file manager in it (the full tree structure)
The user is supposed to be able to select a file from the outline view and then the app will open it.
How am I supposed to do that, given that the app should be 100% sandbox-compliant? Is there any known workaround? Is it even possible?
Any ideas?
Short answer: You can't do that. In order to show the contents of a folder within your app's UI, you'd first have to get the user to open it either using an open panel or dragging it in from the Finder.
You can do this, as #omz said, your application needs to request permission to access the folder containing all the files/folders that your application is showing. You don't need permission of individual files, but can get an entire directory structure as a single permission, and then store that as a security scoped bookmark so future executions of your application will already have that permission.
You could even at app launch ask the user for permission to access the entire hard drive, or their entire user directory.
You can use this class I wrote to wrap all that up into a single function call, which will then persist the permission so they are only asked on first run. https://github.com/leighmcculloch/AppSandboxFileAccess
Alternatively if you want to do it with NSOpenPanel manually, just take a look at the code in AppSandboxFileAccess as it uses it to get permissions and then persist those permissions.