the scenario is like this. I have a file in Google Drive, then share it to public, but not the direct link to my file. see sample here https://ganool.ag/steve-jobs-2015-bluray-720p-ganool-ag/ | scroll down and find link https://file.rocks/file/jBH0tM97Ne (ignore the pirate movie in the link, it's just sample). When you click the link, the file will be copied to your drive account, save in a folder called File.rocks, than a subfolder with random name.
my question is, what API command used in that script? just the concept, not the complete script.
sorry for my english.
The behavior shown in that website is similar to the Save to Drive button which allows the user to save files to their Drive account from an arbitrary URL via their browser.
The technology used to upload files is similar to that used by the Google Drive web user interface. The file is downloaded to the user's browser in parts and uploaded to Google Drive as data is received.
Authorize your app to get code
exchange code for token
create client-folder-id if not exist
then use copy
for example:
POST https://www.googleapis.com/drive/v3/files/<your-file-id>/copy
Authorization: Bearer token...xxxxxx
{
"parents": [
"<client-folder-id>"
]
}
Related
For example we have a link to Google Drive: https://drive.google.com/file/d/1o4bqvKsGjf_yukzt-zQPtZWtqv21gpmv/view?usp=sharing
This file on someone's drive, not on my own. And how to download this file using API, if I know only a link?
The share with me link that you can get via the google drive web application. is not a true form of sharing.
In order to download a file using the api you must first have permission to access that file. That being said you must have a record on the file with your username (email address) returned by a premissions.list call on the file.
Without it when you do a file.list the file will not show up as you do not have permissions on the file.
The issue with the share with me link is that the Id is not the id of the file. So even if the file was public you would not be able to find it.
To be clear a share with me link to a file on google drive does
not contain the true file id needed for the api
grant any true permissions on the file. meaning that you cant access it via the api.
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.
I am trying to automate the user sign up and upload flow of our video editing service.
The current user flow is:
1) User signs up on our website (www.gogramapp.com) using a typeform form.
2) Zapier takes the user email and name from typeform and creates a folder in our google drive with title: [Email, First Name, Last Name]
3) I then want to send the user an email with a link to their google drive folder that has been created. The user uploads their raw video files to that folder. We edit the files and send them back a professionally edited video.
Any ideas on how to get from step 2 to 3?
If you created the directory using the Google Drive zap, then you just add another step that is the email after that? The link is an output from the Google Drive folder creation action.
Alternatively, Google Drive zap can trigger on a new folder created (it is a 'less common' option in the user interface) in a specific folder. You can then attach an email (Gmail or whatever you are using) action to that.
Will that work for you?
If I open the shareable link I have got for a file from Google Drive in the browser, I always get either to the Drive's internal preview program or to a download page (See below).
I would like to know whether there is a programmatic way to launch a specific drive-connected application (with confirmed access permissions) to open a file for which I have the link (and thus, the ID as well).
I don't want to do this through the drive's interface, but rather within my program. Let's say I want to let the users browse their files and open them in the browser with their default app as they have defined it on their drive (and let's say I already know that app).
To make it clear, I just want to achieve what Google Drive's interface does in the browser: You click a file, and it opens in a new tab in your default app.
In my opinion, this is possible with the use of Advanced Drive Service and Drive Service.
Advanced Drive Service
The advanced Drive service allows you to use the Google Drive web API in Apps Script. Much like Apps Script's built-in Drive service, this API allows scripts to create, find, and modify files and folders in Google Drive. In most cases, the built-in service is easier to use, but this advanced service provides a few extra features, including access to custom file properties as well as revisions for files and folders.
and for the Drive Service, you can use getUrl() method to get the URL that can be used to open the File in a Google App like Drive or Docs.
This service allows scripts to create, find, and modify files and folders in Google Drive.
Detailed information and sample codes regarding these services can be found in the documentations.
I am trying to authorize files on my google drive with specific APP authorization I created. As files on my google drive can only be manipulated by its authorized app, is there any way I can convert these "None" authorized file with APP authorization? And, if yes, by which function?
I looked all over the tutorial document but only find discussion about permission. The only method I can think about is uploading these files to google drive with upload function from my created app. But I guess there is a much smarter way. Do any one has the same experience?
Here list my steps to create authorized file:
First, I start my app from using sample code, DrEdit. https://developers.google.com/drive/examples/python;
From the code, I successfully open new files and saw them listed on my google drive.
From view authorized app, I can clear see these apps created from my app have their authorization signed with app ID. The other files original belong to me have these authorization signed as "None".
I had the same issue and had to change the scope from https://www.googleapis.com/auth/drive.file to https://www.googleapis.com/auth/drive which gives full access to all drive files rather than just the ones created by the app.