If you wish to store, change or delete files and folders inside a Dropbox account through a Laravel application automatically, this tutorial will be useful for you. Now imagine if your case is that you have to deploy any Laravel application to ephemeral filesystem server, and you don't want to use Cloud such as Amazon S3 / Cloud, you can integrate your app to use Dropbox as your Storage.
This project has as base, the Composer library / dependencie victor-rayan/dropbox-rayan-vrsrb that is abstracted from Laravel Vendor layer to explore their objects to manage files in Dropbox via HTTP Curl requests. This library provides request methods, being them:
- Upload
- Delete
- Get Access Token by Refresh Token
- Get file access (get file temporary link)
To See in more details the vendor library abstraction and the Laravel Storage use in Controller class FileManager.php
Before execute this project, you need to add the following Environment Variables in .env file or in your server:
DROPBOX_APP_KEY=Your app key
DROPBOX_APP_SECRET=Your app secret
DROPBOX_REFRESH_TOKEN=Your refresh token
- In first place, you must to access the your App Console, and create an app. After created your app, you should to see your App Key, and App Secret.
- To get the Refresh Token you can follow the Dropbox API HTTP Documentation or execute the following URL into yout Browser. You must to get an Authorization Token that can be used once:
https://www.dropbox.com/oauth2/authorize?client_id=&token_access_type=offline&response_type=code - Execute the following Curl Request into your Terminal, or translate this Curl to any programming language and get the your JSON output. You must to replace the GET paramaters with your correspondent velues, such as the Authoriation Token that you have obtained previously.:
curl https://api.dropbox.com/oauth2/token \ -d grant_type=refresh_token \ -d refresh_token=<REFRESH_TOKEN> \ -u <APP_KEY>:<APP_SECRET> - Take the "refresh_token" value from JSON output and put it into your DROPBOX_REFRESH_TOKEN environment variable.
- Simple, fast routing engine.
- Powerful dependency injection container.
- Multiple back-ends for session and cache storage.
- Expressive, intuitive database ORM.
- Database agnostic schema migrations.
- Robust background job processing.
- Real-time event broadcasting.
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
Laravel is accessible, powerful, and provides tools required for large, robust applications.
The Laravel framework is open-sourced software licensed under the. As well as this project too. MIT license.