Skip to content

This is a repository intended to store a Laravel project with Dropbox filesystem Integration.

Notifications You must be signed in to change notification settings

VictorRayan/laravel-dropbox

Repository files navigation

Laravel filesystem integration with Dropbox

Understanding what we want to do:

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.

How was this project made?

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)
  • A method that deserve more attention is Upload. Explining better this method, it will receive two parâmeters, such tal "destination path" in format ("/folder/folder/file.extension") to tell to Dropbox API what is the path to store the new file, and "filepath" that is responsible to carrying the local file path in the Laravel server. Is important to understand that is be necessary to use the Laravel filesystem to store temporary the file into server public storage the get their file path and send the file through Curl request using the file path.

  • 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
    

    Where do I get these tokens?

    • 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.
    • Now you're ready to execute this project!

      About Laravel

      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.

      License

      The Laravel framework is open-sourced software licensed under the. As well as this project too. MIT license.

    About

    This is a repository intended to store a Laravel project with Dropbox filesystem Integration.

    Resources

    Stars

    Watchers

    Forks

    Releases

    No releases published

    Packages