How to Copy Link to Files in Shared Google Drive (Batch copy) - google-drive-api

We use shared google drives and will often link files to one another. E.g., a pdf saved in drive may be discussed in a spreadsheet/doc with a link to drive included. We usually grab these links in a browser or using the "Copy link to clipboard" option on Google Drive for Mac (right click in Finder).
I'm looking to automate some processes and would like to include the Copy Link step as part of the automation.
Digging through the documentation for the google drive api, I've found some options to update permissions, but can't find anything to just copy an existing share link like we do in our workflows.
https://developers.google.com/drive/api/guides/manage-sharing
Does anyone have suggestions on this? We have automation set up in r and python, so options within that would be preferable.

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.

Allow Anyone to Upload Files Directly to my Google Drive

I would like to allow my students to send me one or more files directly to my google drive via a form where they would just enter their name and choose the file(s) to send (drag and drop would be great). A folder with their name would be created in a specific folder on my drive and a warning email would be sent to me. Do you think this is feasible with google script? Thanks in advance.
An example here but paying ...
I've checked and Google Forms already allows for a File Upload kind of question (with drag and drop too).
It automatically creates a folder in your Google Drive (altough it doesnt create a folder for every student) (example here) and in the spreadsheet that it automatically generates there is a permanent link to that file (example here).
If that's not what you are looking for and you need the 'Folder per student' feature then yes, you can use google apps script to move files in folders quite easily.

Why can't i transfer ownership of google drive folder and files to other? (OwnershipTransfer libary is being used)

The library I am using is from here.
The response has very little info to debug or I don't understand what is this. It supposed to be easy from what I read in the description.
Any help?
That's an intended behavior. From your screenshot, I'm assuming you're using a G Suite/Workspace account for your 5times.co.in email. Please take note that transferring files from one Workspace account to another workspace account or Gmail is not possible as of the moment.
This is a documented here: https://support.google.com/a/users/answer/9308960
You can transfer ownership of your Google Drive files and folders to someone else in your organization.
an alternative is to either use Shared Drive or download the file and re-upload it to your Gmail account.
A better way to do this is:
step-1: Transfer files from the drive (your Gdrive) to google cloud storage
step-2: Transfer files from google cloud storage to drive (new Gdrive, different organization)
Reference python code for file transfer between DRIVE & Google drive.
https://colab.research.google.com/drive/1Xc8E8mKC4MBvQ6Sw6akd_X5Z1cmHSNca

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.