I am working to create a script that scans our company Google Drive folders and copies any new files into a Repository directory on my server.
So far I can connect to GDrive, read all files, edit files, but I am unable to download via PHP. copy() file_get_contents() file_put_contents()
etc. Are not working.
I imagine the solution is to use Google Apps Script to download and copy the file to my server directory, but I do not see the correct class.methods in the documentation.
How can I copy a GDrive file to my server using Google Apps Script?
You could run some code through Google Apps Script to upload the files to your server. In that case you need to use UrlFetchApp.fetch
, which despite its name can also do an HTTP POST with arbitrary data. There is an example for uploading files in the API documentation. https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app