Git Product home page Git Product logo

dropbox-public-folder-replacement's Introduction

Dropbox Public Folder Replacement (DPFR)

Dropbox are removing support for the Public folder functionality.

This is a drop-in script replacement for your Dropbox public folder links.

As Dropbox no longer provides the service, DPFR runs on your web host instead. Files are still fetched in real-time from Dropbox using their API.

For example, while your old links might have looked like this:

https://dl.dropboxusercontent.com/u/123456/myfile.txt

Your new links will be sent via your web host and will look like this:

https://mysite.com/dropbox/myfile.txt

Instead of manually generating new Dropbox share links, this enables you to simply change the domain name for your links and be done with it.

Requirements

This script is tailored to run on most conventional web hosts that support a modern version of PHP.

  • PHP 5.5
  • mbstring

Setup

Download the latest release version here. If you don't download the release version you will need to install dependencies via Composer.

Setting up your Dropbox app

DPFR does not support getting files directly from your Dropbox public folder. This is for security reasons. Instead, we will create a special "App folder", and move our files from the Public folder to the new App folder.

  • Go to "My apps" in your Dropbox control panel.
  • In step 1, create a "Dropbox API" app.
  • In step 2, choose "App folder"
  • In step 3, name your app to "Public folder replacement"
  • You will be redirected to the app info page. Write down the App key and App secret
  • In the Oauth2 section, click the "Generate" button and write down the Generated access token

2017-08-19 02_21_44-developers - dropbox

App settings

2017-08-19 02_22_20-my public folder replacement - dropbox

Generating OAuth token

Configuring DPFR

  • Start by uploading the script to your web host.
  • Copy the file config.sample.php to config.php.
  • Edit config.php with the value obtained in the previous step.
    • appKey = App key
    • appSecret = App secret
    • accessToken = Generated access token
  • Move or copy your files from the Public folder to the Apps/Public folder replacement folder.

Web server: Apache

You will need the mod_rewrite apache module enabled for this to work.

Add the following to your .htaccess file:

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</IfModule>

Remove or comment out the ErrorDocument line.

If you have put the script in a subfolder you will need to modify the $urlPath variable by adding an additional line immediately below the line that defines this variable in index.php, eg

$urlPath = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$urlPath = preg_replace( "/^\/my_subfolder/", '', $urlPath);

replace 'my_subfolder' with the name of your folder.

Web server: Nginx

Make sure to rewrite all your requests to index.php. For example this can be done using the following location block:

location / {
    try_files $uri $uri/ /index.php;
}

To-do

  • Add file cache
  • Nicer error page

Pull requests/issues are welcome.

dropbox-public-folder-replacement's People

Contributors

arwystli avatar khromov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

dropbox-public-folder-replacement's Issues

script not working

I have followed the instructions carefully but I am having no luck in getting this to work. All I get is errorcode 500, tried it in browser and using wget

Error from Dropbox on nginx: malformed path

Hi

I'm running this on nginx.

I get this error when I deploy:

{"error_summary": "path/malformed_path/.", "error": {".tag": "path", "path": {".tag": "malformed_path"}}}

Any idea how to fix this? Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.