How can I get a list of all activity on a file created in Google Drive? - google-apps-script

In the "activity list" of my file stored on Google drive, I see a message "File flagged as containing restricted content". I would like to write a script that goes through the activity list of all files I own, and identifies if any other files have been flagged similarly.
Screenshot showing Google Drive Activity: File flagged as containing restricted content
I looked through the the File Class documentation for Google App Script (https://developers.google.com/apps-script/reference/drive/file ) and did not find anything that looked like it would get Activity details of a file object
I am open to suggestions for finding activity information using Google App Scripts, or other methods if available. Please provide some context if suggesting other methods as I am only familiar with Google App Scripts.

Related

Auto-create google docs file when uploading photo to Google Drive

I have a bunch of screenshots (probably in thousands) that I want to run OCR on. I tried different services but Google Drive results are far better. But the process is a little tedious. First I have to upload a photo to Google Drive and then right click the uploaded file and select "Open with -> Google Docs". The resultant doc file contains all the text that was in the screenshot. However, it works for only one file at a time.
So is there a way to tell Google Drive to automatically create the doc file for every photo at the time I upload them.
I know there is Google Drive API that could help in this regard but I have very limited experience with coding and API. I could use a program if available.

Rename files in Google Drive that have been collected through Google Forms

I am collecting Friends photos through a Google Form. The Form has only two fields Name (text) and Photo (upload).
The uploaded photo is stored in a folder in Google Drive and a hyperlink appears in the Google sheet to the name.
The issue I am facing is that the photo stored in Google Drive usually has a name generated while taking the photo and is not the name of the person whose photo it is. I want the photo file name to be the same as the person's name.
I don't know much of Google Scripts and would like help in using a script to rename the files in the Google Drive with the name of the uploader which is in the Google Sheet.
To rename uploaded files in Google Drive that have been collected through Google Forms you can
create your own apps script that will process all files received via Google Form, as described here or here, or
use my Google Forms add-on Form Uploads Manager that renames the uploaded files, move them to the Google Drive folders you specified and can add a description for each uploaded file, which makes it easy to find files using the built-in Google Drive search. A detailed description of the add-on settings is available on the app home page.
Disclaimer: This is my Google Forms add-on, which I created for my own purposes, and after successful use I posted it on the Google Workspace Marketplace. After a 1 week trial (which might be enough to reach your goals), a paid add-on subscription is required.

Search file in other google drives

I have a google drive where am storing few google sheets. My java web application is able to search a file that is present in my own google drive using Javascript API. Is there a way to search for a specific files in other's google drive via code? i will be getting the shareable link to the google drive am supposed to search. can this be done? As far as i checked this is not possible. Also there is no where in google document that says i can search files in other's drive. Kindly someone confirm.
This is an OAuth question, not a GDrive question.
The account that the GDrive API will apply to is determined by the Access Token that it is called with. So, if you can get an Access Token for somebody else's Drive, then you can use that to search their drive. How you would get such a token will depend very much on the details of your use case and the trust relationship.

Google Apps Script - publish google documents and read urls

I'm new to Google apps script.
I can create a number of documents in Google Drive via a script and add content.
I would also like to publish them via a script and record the published URL. Is this possible?
I can see an old answer from 2012
"Publish to the web" for Document in Google Apps Script?
You can create all your content in a publicly shared folder, then once you have the folder's ID, you can create a straightforward base URL (e.g. https://googledrive.com/host/[folder ID]/) and simply append the newly created file names. I asked a question related to this topic a few days ago.
Conversely, you can set the permissions for each file you create then get the download URL's for them individually using getDownloadUrl().

Google Apps Script access Drive SDK API

Is there a way to use the Google Drive API's from Google Apps Script. I am aware of the DocsList Service, which allows you to look at folders and files , however what about all the other API's in Google Drive (Files,About,Changes,Children,Parents,Permissions,Revisions,Apps,Comments,Replies). For example, is there API access to add Comments to files from Google Apps Script.
Apps Script has the ability to access Google API's, but you need to explicitly enable them before they can be used.
In the code editor, choose RESOURCES, ADVANCED GOOGLE SERVICES
Click the OFF button, to turn the service ON.
Before you close the dialog box, click the link at the bottom to open up the API Manager.
Once you've completed those two steps, the Drive API is available inside of Apps Script. Type the key word Drive then type a period, and available methods will show up in a list.
Methods
get - Gets a file's metadata by ID.
insert - Insert a new file.
patch - Updates file metadata. This method supports patch semantics.
update - Updates file metadata and/or content.
copy - Creates a copy of the specified file.
delete - Permanently deletes a file by ID. Skips the trash.
list - Lists the user's files.
touch - Set the file's updated time to the current server time.
trash - Moves a file to the trash
untrash - Restores a file from the trash.
watch - Start watching for changes to a file.
emptyTrash - Permanently deletes all of the user's trashed files.
https://developers.google.com/drive/v2/reference/files#methods
(Google-Apps-Script=GAS) Drive Services added 2013.05.13 (to be announced at the 2013 Google I/O 2 days later) is apparently-exactly designed to replace the prior API(DocsList) and allow GAS to access the Google Drive SDK, though that functionality is currently not mentioned (why?) from those official docs but it is most certainly suggested by the new new API name "Drive" and is stated at as the purpose by Google's great demo video "Integrate Google Drive with Google Apps Script — Google I/O 2013" and "Drive SDK" is mentioned in by the search functions as searchFiles(String).
And Drive Services works (I'm using it; and though I could think of many improvements, haven't found any bugs of memory) including it works for useful apps (see the the video above for one of the most impressive ones I've seen) but it isn't complete (including doesn't expose the full Drive SDK) including:
it doesn't (yet?) allow one to access prior versions of content (as that vide plus (the enhancement request: Google Search for "Issue 2811: Access the document revisions using DriveApp"),
control the indexing status & method of content,
one can't get a list of a file or folder's accessors (apparently deliberately says the video; but using the prior DocsList or Library mentioned seems like it would be a workaround).
I'd have included more links to help out but I'm a new poster here so the editor's telling me "You need at least 10 reputation to post more than 2 links.".
Yes, it's possible.
Take a look at the documentation for Class File, which includes functions for obtaining and/or changing most of the attributes you've listed.
For an example of code that gets some of this info for files and folders, see this answer.
You should also have a look at this Library written by Romain Vialard, one of the GAS TC.
It provides functions that are not available directly in gas or - at least - not as simply.