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.
Related
I am using my google drive space to host my website (I followed the instructions here in this video: https://www.youtube.com/watch?v=qtQ9TvQLKjc&t=291s) and it is all functional and working except the PHP forms in my HTML website template!
When I contacted BootstrapeMade.com where I purchased my website template from, they told me that the reason is that my hosting does not provide PHP support.
I searched online but I couldn't find anything useful and google drive API documentation is overwelmingly poor written. So I was wondering if there is anybody here who can help me answering this questions for me: What is the best way to use PHP forms on my Google Drive hosted website? Is it even possible? If yes, how exactly?
No, you can not execute any PHP code on google drive. PHP is a backend development language and you need a server to execute it. Google Drive works like storage, and you can only share your HTML, CSS, JS files publicly on it.
I would like to allow my users to upload files from an html / php form from my site to my personal onedrive account. Then get the sharing links from these files.
I looked at microsoft.com and stackoverflow, but I do not understand how to upload the file directly into my account and not the user's.
Thank you very much for helping me find the trick or the piece of code to make it happen!
https://learn.microsoft.com/en-us/onedrive/developer/rest-api/concepts/upload?view=odsp-graph-online
Use flysystem. https://flysystem.thephpleague.com/docs/usage/filesystem-api/
Then all your storage stuff uses a really easy to use similar API. Then just add the onedrive adapter, and you can call it the same way you call any of the others :-)
https://packagist.org/packages/nicolasbeauvais/flysystem-onedrive
I'm wondering if I can use OneDrive for saving integration files between two web apps, so I have to create file and save it to OneDrive on specific folder but this process should be in background using username and password for OneDrive account, so the end user should not see the Microsoft login page or asking them about this app to allow access to his info, (by the way I don't need any information from end user) All what I want is to upload the integration files to specific OneDrive account on specific action exactly same FTP on PHP.
Please any suggestions or solutions?
It's solved by using this client for Microsoft OneDrive on Linux "onedrive-d":
https://github.com/xybu/onedrive-d-old
Wich can help
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
Each time a file is uploaded in a specific Google Drive folder, I would like to create a new entry in my CRM.
Since I'm using PHP, I think I might have to run a cron to check for the new files in Google Drive, then report them into my CRM.
But I was wondering, is there a way to tell Google to run my script each time a file is uploaded into a specific folder, thus avoiding the use of crons?
Thanks in advance.
It seems that Google provides a push notification system.
https://developers.google.com/drive/web/push
I still have to test it, but if there is a solution to my problem I think it's this feature ;-)
Thanks to #AndréSchild for his help.