I am new here and newbie in Google Drive thing. I managed to follow and install Google Drive v3. Now, I am stuck as to how can I make a simple PHP code that will upload a text file to my Google Drive. I need a simple PHP code / guide on how to upload a small text file. Please help.
Thanks in advance.
If you want to know how to upload file, then you can check the DRIVE API documentaion for that.
Here you can find 3 options on how to upload file.
simple upload
multipart upload
resumable upload
Just visit the above link to know more about them.
For the PHP code that you want, then you can check the answer in this SO question.
Just remember that you need to set <YOUR_REGISTERED_REDIRECT_URI> to the document to authenticate it.
For more information or other way to upload file using service account, check this SO question.
If you want to understand the process of file upload on google drive.
There is a repository on GitHub on how to authenticate and upload files on google drive using Google Drive API in PHP. You can give it a try.
https://github.com/SM4991/php-google-drive
Related
I have bee looking for a way for my web app users be able to upload files but avoid filling the limited hosting space I have. Google drive sounded like a perfect fit but now i'm stuck at how to use PHP for uploading files to my gdrive using a service account. Any help or advice is greatly appreciated.
Edit:
Was able to upload files using oAuth but I don't want my web app users to upload their files on their own Drive but mine. I think using the service account is the right road to go but i'm still scratching my head on to go about using it.
How to upload a file to Google Drive using the API by a url(Remote Upload)? I read the doc and I did not find any option like DropBox where save_url() can be used to remote upload.
But, there are a lot of sites which allows remote upload to Google Drive, so it must be possible.
You may refer with this tutorial on how to directly upload files from the web to Google Drive without saving them completely on the server before. This is useful to upload files, which are bigger than the storage available on the server.
How to use it:
Rename "credentials/oauth-credentials_EXAMPLE.json" to "credentials/oauth-credentials.json"
Download your oauth2 credentials in the google developer console and copy it in it
Call the "index.php" from the console ("php index.php")
Follow the messages in the console window
Create pull requests to help with the development
Hope this helps!
I have tested and used Google's resumable upload code sample. Based on that, if I use HTML5's upload file API, I would have to upload the file to the server first then post the video's name to Google's resumable upload php file, right? If so, then this would mean a very long upload process because I'm uploading to two servers consecutively.
Hence, my question title. Is it possible? If so, please point me to the right direction or simple tutorials using YouTube API v3 to get started. Thank you very much!
P.s. I've heard of Zend Framework but I don't want to install the whole thing just to use a simple YouTube upload. Please guide me by extending the usage from Google's code sample.
Two possible approaches right now.
Browser based upload via YouTube API v2 (scheduled to be removed april 2015)
https://developers.google.com/youtube/2.0/developers_guide_protocol_browser_based_uploading
CORS upload with API v3.
SO Question with details
So far, I've built a PHP script that downloads to a remote server of mine a file from Internet, provinding its URL (I've used this piece of code to download to the server).
Now I would like to upload the downloaded file on Google Drive using its API.
My question is: Is there a way to download the file directly to Google Drive, without using the server? Or I am forced to download the file first to the server and then upload it to Google Drive?
Thank you
I doubt if you can 'make' google drive get file from an external location...
However you do have an option to create a shortcut to the external file, if that suits you.
Also, If you wish continue direct upload you may refer this.
As far as I know the API doesn't allow to push files from another referer than the one that's calling the API. So, long story short:
First you need to download the file to your server, then upload it to gDrive from your server.
Read here more: https://developers.google.com/drive/examples/php#saving_files
Or here: https://developers.google.com/drive/manage-uploads
I have many many pdf files around 50GB in my Ebooks folder.
Now i want to upload them in Google docs like Rsync of Linux.
Is it possible to have the script in php or python which uploads all pdf files in Ebooks folder and subfolders to Google docs.
Now the problem is i need to restart computer many times and i want that script should start from where it was left with previous file so that i don't need to manually make selection of files. is it possible
You'd use the Google Documents API to upload them using a simple HTTP POST with the data. Here's an explanation how to upload and convert documents: http://code.google.com/apis/documents/docs/3.0/developers_guide_protocol.html#UploadingDocs
The link will provide you will examples and all you need to do what you were asking for.
To be more precise this is what you are looking for if you want to upload pdf's: http://code.google.com/apis/documents/docs/3.0/developers_guide_protocol.html#ResumableUploadPUT
Python Google Documents API guide
PHP Google Documents API guide