![]() ![]() ![]() We save the folderID of this client so that we can later navigate there or delete it if needed. We also need to have a main folder different from the root Google Drive folder, that's why we use the ' parents', which takes the value of the folder from the env file. ![]() In our project requirement, we need to create a folder for each client. Just like in the article, we need the following code to establish the connection with Google Drive: $client = new \ Google_Client ( ) $client -> setClientId ( env ( 'GOOGLE_DRIVE_CLIENT_ID' ) ) $client -> setClientSecret ( env ( 'GOOGLE_DRIVE_CLIENT_SECRET' ) ) $client -> refreshToken ( env ( 'GOOGLE_DRIVE_REFRESH_TOKEN' ) ) $service = new \ Google_Service_Drive ( $client ) Let's say that you are sending a request from your create view, and now we are accepting that request on our store function. All the coding will be done inside a controller, so create a controller and start coding. We have used Laravel Facades to refactor our code, but we won't get into that now, to keep this article simple. We will assume that you have finished the setup and managed to create a simple file on your Google Drive, as shown on the article. In case you need to upload files, get their id, delete or change their names, feel free to continue reading. If that's all you need, skip reading this article. The guide is very easy to follow and it even shows how to create a new file in your connected Google Drive folder. Google Drive recognizes the files through their IDs and not their names.īefore starting to code, we need to setup the connection with Google Drive API, and we can do that easily by looking at the following link here. We found many solutions for creating a new file in Laravel, but it was very difficult or almost impossible to get the id of that file. In a recent project for a client, we had to integrate Laravel with Google Drive, as the main filesystem. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |