BOX does not emit any event for the files residing inside a copied/duplicated folder - box-api

To retrieve all the events in our Box account, we are utilising the Box /events api (doc-https://developer.box.com/reference/get-events/). When using the Box UI to copy a folder (folder1) containing files to any location, only the COPY event type is received for the parent folder (folder1 (1)), and no events are received for the files included within the copied folder.
The identifiers of each file in the cloned folder, however, differ from those of the files in the original folder. For those files, a COPY event was also what we were expecting.
Is there something that can be done to get events for those duplicate files?
Posted this query in the Box community as well but didn't get any response.

Related

Get new file id after transferOwnership=true and moveToNewOwnersRoot=true

I need to move a file from one user in our domain to another. I am accomplishing this by creating a new Permission and setting transferOwnership and moveToNewOwnersRoot to true. It works fine.
But after I move the file to the new owner's root, I want to move it into a nested folder. I can do that with a PATCH to the /drive/v3/files/fileId endpoint, but I need to know what the file id is. When the create permission call moved the file, the file get's a new id, but I can't see a way to get it. The create permission call returns a permission, not the associated file. Is there a way to get the file id from a permission id?
Thanks DalmTo, you are correct that the file id does not change just because you transfer ownership. Makes sense. It works now that I'm not making a false assumption, but it's so slow. I'm making 4 API calls just to copy a file into another user's drive in a mirrored folder structure.
Copy the file on the origin user's drive
Share the copied file with the destination user in order to prevent an email notification being automatically sent out to the origin user during the ownership transfer (an email notification is still sent to the destination user, but that's ok).
Transfer the copied file to the destination user's root.
Set the parent of the copied file to the folder id that mirrors the origin user's parent folder.
Wish there was a way to combine some of these calls, and I may need to do more to check for existing share permissions, for example. And this is for every file. I don't understand why this use case isn't better supported by the Drive API.

Providing the respondent with the file upload in the form

I continue to expand my project - the problem described at Selecting a subfolder to upload based on the response has been successfully resolved. Therefore, I am looking for a solution to the following problem. The respondent is to submit the file using the form. How to send him a link to this file (with download permissions but not editing) or send the file itself (e.g. by e-mail).
Folders are created based on the responses from the form, so at the stage of creating the form, I do not know the names and IDs of these folders.
I understand that you already have developed scripts for «emailing a file that is already on Google Drive or for sending a link to such a file», and your goal is to run such scripts when a file is uploaded to a Form. If my understanding of your scenario is correct, then you are very close to reaching your goals.
First of all let me clarify that the files uploaded on Form populate a Drive folder automatically. You can see in your main Drive folder (My Drive) that there is one folder for your form, and inside that folder there is one additional folder for every question in your form that requires a file upload. Please keep in mind that all respondent users will share the same folders.
Knowing the fundamentals discussed above, you only need one additional function to connect the new files in your Drive folder to your already existing scripts for mailing the files. To do so you can set up a form submit trigger that fires your scripts. To connect your scripts with the forms responses folder, you should copy the folder ID into your function. Let me know if you need further clarifications with this approach.

Tracking changes in "shared drive"

I've been using a Google service account to track changes in a folder located in My Drive.
This folder is shared read-only with the service account.
Normal operation
First time I'm running these steps
Get a startPageToken
List all files and save a local copy
Next time I only do these steps
Get changes.list
Shared Drive
Since then I've moved this folder into a Shared Drive/Team Drive where I added the service account with view permission to the whole shared drive.
After this change I can still list all files but the changes API always return an empty list of changes.
API Explorer/OAuth
So I tried to do the same using the API explorer using my user account/OAuth 2.0.
The result is the same, I can list files but I can't get any changes to appear.
I get a new startPageToken, response: 1207
Make changes in a google documents inside the Shared Drive
Request changes.list using the following
pageToken=1207
driveId=XXXXXXX
includeItemsFromAllDrives=true
spaces=drive
supportsAllDrives=true
The result is an empty array of changes and newStartPageToken being the same value as the pageToken I specified in the call.
{
"kind": "drive#changeList",
"newStartPageToken": "1207",
"changes": []
}
I've also tried without specifying driveId with the same results.
List files
The changed files that doesn't appear in the changes.list call can be found using the files.list call. Though this requires me to scan through all files every time I want to know what files changed.

Use Google Apps Script to Assign a File to Multiple Folders - Like Shift+Z Feature

In the Google Drive interface, a file can be assigned multiple folders by using the Shift+Z feature. I am working a Google Apps Script project that will create a folder for each user in a spreadsheet. It will also make copies of selected documents into the newly created folders.
What I am trying to find out though, is I have a specific document that I would like to add to those new folders, but I do not want to simply make copies. I also do not want to simply move the file. The Shift+Z feature allows me to have the document in multiple places at once, changes to that document are reflected regardless of the folder. Can this be done with script?
In Google Drive, a file can have more than one parent folder. The addFile() method of the Folder class will add the file to the folder you are calling the method on.
https://developers.google.com/apps-script/reference/drive/folder#addFile(File)

How to retrieve sub-folder,files of a deleted folder in Trash from BOX account using V2 API?

How to get the sub-folders and files of a deleted folder in Trash using BOX API V2?. I tried using the request pattern like: https://api.box.com/2.0/folders/{id}/trash/items. But it doesn't work for me and it returns me only the info about the same folder.As well as how to download the content of a deleted file?.
Thanks in advance....
Currently you must restore the item from the trash before you can access its contents (for folders) or download it (for files).