Code Monkey home page Code Monkey logo

flysystem-dropbox's Introduction

Flysystem adapter for the Dropbox API

Latest Version on Packagist Tests Total Downloads

This package contains a Flysystem adapter for Dropbox. Under the hood, the Dropbox API v2 is used.

Using Flystem v1

If you're using Flysystem v1, then use v1 of flysystem-dropbox.

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Installation

You can install the package via composer:

composer require spatie/flysystem-dropbox

Usage

The first thing you need to do is to get an authorization token at Dropbox. A token can be generated in the App Console for any Dropbox API app. You'll find more info at the Dropbox Developer Blog.

use League\Flysystem\Filesystem;
use Spatie\Dropbox\Client;
use Spatie\FlysystemDropbox\DropboxAdapter;

$client = new Client($authorizationToken);

$adapter = new DropboxAdapter($client);

$filesystem = new Filesystem($adapter, ['case_sensitive' => false]);

Note: Because Dropbox is not case-sensitive youโ€™ll need to set the 'case_sensitive' option to false.

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

composer test

Contributing

Please see CONTRIBUTING for details.

Security

If you've found a bug regarding security please mail [email protected] instead of using the issue tracker.

Postcardware

You're free to use this package (it's MIT-licensed), but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.

Our address is: Spatie, Kruikstraat 22, 2018 Antwerp, Belgium.

We publish all received postcards on our company website.

Credits

License

The MIT License (MIT). Please see License File for more information.

flysystem-dropbox's People

Contributors

adrianmrn avatar akoepcke avatar alex-d avatar alexmanase avatar alexvanderbist avatar bhulsman avatar busterneece avatar clprosser avatar dmitriilopotovskii avatar freekmurze avatar grahamcampbell avatar gummibeer avatar jmsche avatar joe-walker avatar lianee avatar olsgreen avatar patinthehat avatar robbytaylor avatar samuelhgf avatar sebastiandedeyne avatar srmklive avatar thenodi avatar zaclummys avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flysystem-dropbox's Issues

Dropbox Refresh token needed - Long Lived Access Tokens Depecrated

Prior to : #86 and #95

I wanted to ask you if a new PR was necessary now that Dropbox has an updated way to work with tokens. It needs to generate a Refresh token beforehand. I added my way of working in the issue 86.

Since mid 2021, it is now mandatory to use the dropbox refresh token process :

In the past, the Dropbox API used only long-lived access tokens. 
These are now deprecated, but will remain available as an option in the Developer console for compatibility until mid 2021.

I tried something else personally, without using AutoRefreshingDropBoxTokenService [ not necessary when using the flysystem-dropbox ] and it is less verbose :

You will still need to authorize the access to the Dropbox App using this link :

https://www.dropbox.com/oauth2/authorize?client_id<YOUR_APP_KEY>&response_type=code&token_access_type=offline

This will give you the authorization_code needed to retrieve a refresh_token with this curl request :

curl https://api.dropbox.com/oauth2/token -d code=<ACCESS_CODE> -d grant_type=authorization_code -u <APP_KEY>:<APP_SECRET>

Giving you access to the refresh_token needed in the DROPBOX_REFRESH_TOKEN indicated below . The other elements are available in your Dropbox App.

.env.example

DROPBOX_APP_KEY=
DROPBOX_APP_SECRET=
DROPBOX_REFRESH_TOKEN=
DROPBOX_TOKEN_URL=https://${DROPBOX_APP_KEY}:${DROPBOX_APP_SECRET}@api.dropbox.com/oauth2/token

config/filesystems.php


        'dropbox' => [
            'driver' => 'dropbox',
            'token_url' => env('DROPBOX_TOKEN_URL'),
            'refresh_token' => env('DROPBOX_REFRESH_TOKEN'),
        ],

app/Providers/DropboxServiceProvider.php

use Illuminate\Contracts\Foundation\Application;
use Illuminate\Filesystem\FilesystemAdapter;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\ServiceProvider;
use League\Flysystem\Filesystem;
use Spatie\Dropbox\Client as DropboxClient;
use Spatie\FlysystemDropbox\DropboxAdapter;
use GuzzleHttp\Client;


class DropboxServiceProvider extends ServiceProvider
{
    public function boot(): void
    {
        Storage::extend( 'dropbox', function( Application $app, array $config )
        {
            $resource = ( new Client() )->post( $config[ 'token_url' ] , [
                    'form_params' => [ 
                            'grant_type' => 'refresh_token', 
                            'refresh_token' => $config[ 'refresh_token' ] 
                    ] 
            ]);

            $accessToken = json_decode( $resource->getBody(), true )[ 'access_token' ];

            $adapter = new DropboxAdapter( new DropboxClient( $accessToken ) );

            return new FilesystemAdapter( new Filesystem( $adapter, $config ), $adapter, $config );
        });
    }
}

A PR in code and documentation should be interesting. Should I PR this ? The previous code is also indicated in the Laravel 10 Documentation - Custom Filesystems

getTemporaryLink

Hi, I'm trying to get the temporary link with:

Storage::disk('dropbox')->getTemporaryLink($path);

But I'm getting:

Call to undefined method League\Flysystem\Filesystem::getTemporaryLink

I appreciate your help.

File download with Dropbox ID

Hi,
Thank' for this package!

I found a mistake:

Action:

I try to download file using his Dropbox ID (id:xxx)

Error:

File not found at path: id:xxx

Investigation:

After investigation I think the mistake is on applyPathPrefix method.

After prefix apply, API call param is /id:

Solution:

Quick dirty fix for me:

    /**
     * {@inheritdoc}
     */
    public function applyPathPrefix($path): string
    {
        if (Str::startsWith($path, 'id:')) {
            return Str::replaceFirst('/id:', 'id:', parent::applyPathPrefix($path));
        }
        return parent::applyPathPrefix($path);
    }

Cannot upload file which size is a multiple of chunk size

When trying to upload a file which size is a multiple of chunk size the upload ends in a endless loop.
After uploading all contents it constantly tries to upload another 0 bytes.
This is not the case when file size is equal to chunk size - it has to be a multiple.

Anything that i can tell to help is that GuzzleHttp\Psr7\Stream::eof() is returning false all the time.

Include the service provider in the package

Would it perhaps be a good idea to include the service provider mentioned in the blog post in this package? It feels a bit weird we still have to extend the storage adapter manually when that's the main use-case for most. Creating and maintaining a custom Dropbox service provider for each project that uses it (and I have a lot of projects depending on it) is also quite redundant.

use token per User

Good day, sorry for writing here, I need to save the dropbox tokens in a database for each user, so that when the logged user uploads a file it is saved in his personal dropbox. Some advice or example I would appreciate very much.

DropboxAdapter::listContents() doesn't take "has_more" value into account

Currently, DropboxAdapter::listContents() calls Client::listFolder(), does some processing on $result['entries'] if any are present, and returns the entries.

If I understand correctly, I think that this needs to also take into account the possibility that not all results are returned with the first request and instead $result['has_more'] may be TRUE, which means that Client::listFolderContinue($result['cursor']) should be called in a loop, collecting all entries until $result['has_more'] is FALSE.

The code for listContents() could be changed to something like this:

public function listContents($directory = '', $recursive = false): array
{
    $location = $this->applyPathPrefix($directory);

    $result = $this->client->listFolder($location, $recursive);
    $entries = $result['entries'];

    while ($result['has_more']) {
        $result = $this->client->listFolderContinue($result['cursor']);
        $entries = array_merge($entries, $result['entries']);
    }

    if (! count($entries)) {
        return [];
    }

    return array_map(function ($entry) {
        $path = $this->removePathPrefix($entry['path_display']);

        return $this->normalizeResponse($entry, $path);
    }, $entries);
}

Any way to support retrieving URLs?

Hi everyone,

I am not too familiar with this flysystem and with Dropbox in general, but are we able to retrieve URLs with this? Or am I doing something wrong?

Thanks,

Chris

Download very slow

Do you experience any very slow download experience ?
Actually, to synchronise just an html theme (25 files for 2Mb), it takes from 30s to 60s.

Here is my code :

$manager = new MountManager(['remote' => $this->getRemoteFileSystem(), 'temp' => $this->temp]);
        $remote = 'remote://';
        $temp = 'temp://';

        $files = $manager->listContents($remote, true);
        foreach ($files as $file) {
            if ($file['type'] === 'file') {
                $manager->copy($remote . $file['path'], $temp . $path . '/' . $file['path'], ['disable_asserts' => true]);
            }
        }

Have you some advices to drastically increase just download speed ?
Thanks in advance !

"Client error: `POST https://api.dropboxapi.com/2/files/list_folder` resulted in a `401 Unauthorized

image

exception: "GuzzleHttp\Exception\ClientException"
file: "C:\laragon\www\moravaim\vendor\guzzlehttp\guzzle\src\Exception\RequestException.php"
line: 113
message: "Client error: `POST https://api.dropboxapi.com/2/files/list_folder` resulted in a `401 Unauthorized` response:โ†ต{"error_summary": "missing_scope/", "error": {".tag": "missing_scope", "required_scope": "files.metadata.read"}}โ†ต"
trace: [{file: "C:\laragon\www\moravaim\vendor\guzzlehttp\guzzle\src\Middleware.php", line: 69,โ€ฆ},โ€ฆ]

Wrong php version detection

Hello,

I have php 7 installed on my system:
image

but when i try to install this package i get an error:
image

What should i do? It thinks that i have php 5.~ installed but i have 7.~

Thanks

Empty array when show files within a path

I can display the dropbox folder and files using this spatie/dropbox-api

$client = new \Spatie\Dropbox\Client($authorizationToken);
$folder = $client->listFolder('path');

However, using this will ouput me an array without anything

// In laravel

$storage = Storage::disk('dropbox')->files('path');

Checking for file or directory

Hi,
I was previously using flysystem 1.1.10, barryvdh/elfinder-flysystem-driver v0.3.0 and spatie/flysystem-dropbox 1.2.3, and all was well.
Upgraded to bookworm, PHP8.2, flysystem 3.15.1, elfinder-flysystem-driver v0.4.3 and spatie/flysystem-dropbox 3.0.0, and every operation leads to a PHP Fatal error, because the driver gets confused when checking fileExists() for a directory and getting a true value, considering the directory is a file.
That and the fact that PHP8 now triggers a fatal error for wrong return types when the driver tries to get the mime type of a directory.
I think that the check for fileExists() and directoryExists() should return true only if the element is of the desired type, not only if it exists.

PHP Fatal error:  Uncaught TypeError: League\Flysystem\Filesystem::mimeType(): Return value must be of type string, null returned in /var/www/sw3/000_common/common/vendor/league/flysystem/src/Filesystem.php:150
Stack trace:
#0 /var/www/sw3/000_common/common/vendor/barryvdh/elfinder-flysystem-driver/src/Driver.php(254): League\Flysystem\Filesystem->mimeType()

Problem while using appKey and appSecret for creating client.

Documentation says there are two ways to create a client.

  1. $client = new DropboxClient($config['authorization_token']); with token
  2. $client = new DropboxClient([$config['appKey'],$config['appSecret']]); with App key and App secret

First one is working properly, files showup on dropbox when backup is run.Second one is not, it doesn't show any error, it also says backup to dropbox is successfull, but when I check the dropbox, there is nothing there. Even more if I put intentionally wrong secret and key, it still shows backup is successfull.

Dropbox says permanent tokens will be deprecated in future, shortlived tokens are not good for production. Key-secret is not working properly. Can someone have a look into this?

Retriving files/directories from nested path results in empty array.

Ok so after a bit of research and breakpoint debugging, I found out where the problem lies.
This function inside laravel\vendor\league\flysystem\src\Util\ContentListingFormatter.php is what cause the case sensitivity problem:

private function isDirectChild(array $entry)
{
    return Util::dirname($entry['path']) === $this->directory;
}

this check if the entry is child of the directory but it uses case sensitive comparison, which is wrong in out case cause Dropbox is case insensitive, and the listFolder call returns wrong case on non-last folders.

I fixed editing the function to compare strings ignoring case as it follows:

private function isDirectChild(array $entry)
{
    return (strcasecmp(Util::dirname($entry['path']), $this->directory) == 0);
}

I know this is not a problem related to the spatie/flysystem-dropbox package itself, but it could be useful for it to override that function to prevent this kind of unwanted behaviours.

Hope this helps.

Support of Filesystem Disks 'root' variable

Hi,

Just a question here, not a bug - I think. Anyway to make the use of Filesystem with a root folder?

I tried like my other disks but seems to be ignored and always start at the root of Dropbox.

2017-11-19 002319

I suspect this is ignored by the Dropbox API, but maybe I am missing something.

Class cache does not exist error

I use this package with laravel-backup, and if I add the new spatie provider to app.php I get the error in the title. But only on my live server. If I comment out the provider in app.php, of course the backup doesn't work but my site run, and no cache error happens.
Any idea what should be the problem? And why I don't have any issue on local dev environment? At local db backup made and upped to dropbox as it should.
the code base is the same, of course, I deploy the code with git.

How the Dropbox storage driver could be related to cache handling?

I use Laravel 5.5 latest.

thanks

Unable to install on Laravel 8.35.1 - requirements could not be resolved to an installable set of packages

Trying to install but getting the following error:

forge@example-dev-1:~/devapi.example.com$ composer require spatie/flysystem-dropbox
Using version ^2.0 for spatie/flysystem-dropbox
./composer.json has been updated
Running composer update spatie/flysystem-dropbox
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - spatie/flysystem-dropbox[2.0.0, ..., v2.x-dev] require league/flysystem ^2.0.4 -> found league/flysystem[2.0.4, 2.x-dev] but the package is fixed to 1.1.3 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
    - Root composer.json requires spatie/flysystem-dropbox ^2.0 -> satisfiable by spatie/flysystem-dropbox[2.0.0, 2.0.1, 2.0.2, v2.x-dev].

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.

Installation failed, reverting ./composer.json and ./composer.lock to their original content.

I have the latest version of spatie/laravel-backup installed and I believe this might be due to a conflict with line 29 of composer.json in spatie/laravel-backup where it is requiring "league/flysystem": "^1.0.49|^2.0",

Couldn't quite figure out how to resolve the problem on my own, so creating the issue here.

getThumbnail returning bytes not json

Thanks for developing this plugin for flysystem.

I'm finding that $client->getThumbnail returns a stream/bytes? and not json.

If I view the $response variable I see:

[dropbox-api-result] => Array ( [0] => {
	"name": "201603_2347_bdchf_sm.jpg", 
	"path_lower": "/201603_2347_bdchf_sm.jpg", 
	"path_display": "/201603_2347_bdchf_sm.jpg", 
	"id": "id:eQBjXguYjVAAAAAAAAAAEA", 
	"client_modified": "2018-03-21T13:31:28Z", 
	"server_modified": "2018-03-21T13:31:28Z", 
	"rev": "8a0d7e690", 
	"size": 22251, 
	"media_info": {".tag": "metadata", "metadata": {".tag": "photo", "dimensions": {"height": 298, "width": 300}}}, 
	"content_hash": "0e8a8cc17ed87dcc12668657320d7cf2e0733ce9fbee1fa5fc0da9220d97842f"} )

So I know it's there. But how do I get it?

Thanks

Dropbox Refresh token needed - Long Lived Access Tokens Depecrated

Prior to : #86

I wanted to ask you if a new PR was necessary now that Dropbox has an updated way to work with tokens. It needs to generate a Refresh token beforehand. I added my way of working in the issue 86.

Since mid 2021, it is now mandatory to use the dropbox refresh token process :

In the past, the Dropbox API used only long-lived access tokens. 
These are now deprecated, but will remain available as an option in the Developer console for compatibility until mid 2021.

I tried something else personally, without using AutoRefreshingDropBoxTokenService [ not necessary when using the flysystem-dropbox ] and it is less verbose :

You will still need to authorize the access to the Dropbox App using this link :

https://www.dropbox.com/oauth2/authorize?client_id<YOUR_APP_KEY>&response_type=code&token_access_type=offline

This will give you the authorization_code needed to retrieve a refresh_token with this curl request :

curl https://api.dropbox.com/oauth2/token -d code=<ACCESS_CODE> -d grant_type=authorization_code -u <APP_KEY>:<APP_SECRET>

Giving you access to the refresh_token needed in the DROPBOX_REFRESH_TOKEN indicated below . The other elements are available in your Dropbox App.

.env.example

DROPBOX_APP_KEY=
DROPBOX_APP_SECRET=
DROPBOX_REFRESH_TOKEN=
DROPBOX_TOKEN_URL=https://${DROPBOX_APP_KEY}:${DROPBOX_APP_SECRET}@api.dropbox.com/oauth2/token

config/filesystems.php


        'dropbox' => [
            'driver' => 'dropbox',
            'token_url' => env('DROPBOX_TOKEN_URL'),
            'refresh_token' => env('DROPBOX_REFRESH_TOKEN'),
        ],

app/Providers/DropboxServiceProvider.php

use Illuminate\Contracts\Foundation\Application;
use Illuminate\Filesystem\FilesystemAdapter;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\ServiceProvider;
use League\Flysystem\Filesystem;
use Spatie\Dropbox\Client as DropboxClient;
use Spatie\FlysystemDropbox\DropboxAdapter;
use GuzzleHttp\Client;


class DropboxServiceProvider extends ServiceProvider
{
    public function boot(): void
    {
        Storage::extend( 'dropbox', function( Application $app, array $config )
        {
            $resource = ( new Client() )->post( $config[ 'token_url' ] , [
                    'form_params' => [ 
                            'grant_type' => 'refresh_token', 
                            'refresh_token' => $config[ 'refresh_token' ] 
                    ] 
            ]);

            $accessToken = json_decode( $resource->getBody(), true )[ 'access_token' ];

            $adapter = new DropboxAdapter( new DropboxClient( $accessToken ) );

            return new FilesystemAdapter( new Filesystem( $adapter, $config ), $adapter, $config );
        });
    }
}

A PR in code and documentation should be interesting. Should I PR this ? The previous code is also indicated in the Laravel 10 Documentation - Custom Filesystems

dropbox - no disk set for backup destination

hello, i am able to do use local without a problem, but when i use dropbox driver i run into errors.

in terminal i get

Copying zip failed because: There is no disk set for the backup destination.

when i review the email, here's the error it gives me

Important: An error occurred while backing up Short Term Training Database

Exception message: There is no disk set for the backup destination

Exception trace: #0 /Users/sherwin/apps/laravel/sttdb/vendor/spatie/laravel-backup/src/BackupDestination/BackupDestination.php(78): Spatie\Backup\Exceptions\InvalidBackupDestination::diskNotSet() #1

when i run backup:clean i get a

invalid driver [dropbox] is not supported

i've checked your blogged, i've destroyed the app api and recreated a new one. i googled issues relating to this and tried different things from those posts. not sure what else i'm missing. please help.

i'm using laravel 5.4.27, mysql 5.7.16

thanks.

too many requests when uploading backup file

Hi,
We use dropbox adapter to backup our database using spatie laravel backup, we start noticing this error after our backup zip file surpassed 28 GB

Error:

Client error: POST https://content.dropboxapi.com/2/files/upload_session/append_v2 resulted in a 429 Too Many Requests response:
{"error_summary": "too_many_requests/..", "error": {"reason": {".tag": "too_many_requests"}, "retry_after": 15}}

Trace:

{
    "code": 429,
    "file": "/var/aa/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113",
    "trace": [
        "/var/aa/vendor/guzzlehttp/guzzle/src/Middleware.php:69",
        "/var/aa/vendor/guzzlehttp/promises/src/Promise.php:204",
        "/var/aa/vendor/guzzlehttp/promises/src/Promise.php:153",
        "/var/aa/vendor/guzzlehttp/promises/src/TaskQueue.php:48",
        "/var/aa/vendor/guzzlehttp/promises/src/Promise.php:248",
        "/var/aa/vendor/guzzlehttp/promises/src/Promise.php:224",
        "/var/aa/vendor/guzzlehttp/promises/src/Promise.php:269",
        "/var/aa/vendor/guzzlehttp/promises/src/Promise.php:226",
        "/var/aa/vendor/guzzlehttp/promises/src/Promise.php:62",
        "/var/aa/vendor/guzzlehttp/guzzle/src/Client.php:187",
        "/var/aa/vendor/guzzlehttp/guzzle/src/ClientTrait.php:95",
        "/var/aa/vendor/spatie/dropbox-api/src/Client.php:636",
        "/var/aa/vendor/spatie/dropbox-api/src/Client.php:534",
        "/var/aa/vendor/spatie/dropbox-api/src/Client.php:477",
        "/var/aa/vendor/spatie/dropbox-api/src/Client.php:445",
        "/var/aa/vendor/spatie/dropbox-api/src/Client.php:402",
        "/var/aa/vendor/spatie/flysystem-dropbox/src/DropboxAdapter.php:92",
        "/var/aa/vendor/league/flysystem/src/Filesystem.php:68",
        "/var/aa/vendor/spatie/laravel-backup/src/BackupDestination/BackupDestination.php:87",
        "/var/aa/vendor/spatie/laravel-backup/src/Tasks/Backup/BackupJob.php:292",
         ...

Thanks

Download-Progress

When working with mid-size or large files it's actual always required to have a kind of progress information.
Especially, when the connection is pretty busy and you want to inform your client/user with a progress-bar while downloading.
what can I do to get such information while downloading a file ?

Access token expiration

Hi,
I am using spatie/flysystem-dropbox (^1.2) and I get dropbox directories with:
$dirs = Storage::disk('dropbox')->directories();
or files with:
$files = Storage::disk('dropbox')->files($foldername);

I wrote these 2 variable in .env file:
DROPBOX_ACCESS_TOKEN=sl.BLOC_r...
DROPBOX_APP_SECRET=...

I got DROPBOX_ACCESS_TOKEN here https://www.dropbox.com/developers/apps

After 4 hours I get this error:

Client error: POST https://api.dropboxapi.com/2/files/list_folder resulted in a 401 Unauthorized response:
{"error_summary": "expired_access_token/.", "error": {".tag": "expired_access_token"}}
{"exception":"[object] (GuzzleHttp\Exception\ClientException(code: 401): Client error: POST https://api.dropboxapi.com/2/files/list_folder resulted in a 401 Unauthorized response:
{"error_summary": "expired_access_token/.", "error": {".tag": "expired_access_token"}}
at /home/xxx/laravel/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113)

I manually solve it going back to https://www.dropbox.com/developers/apps, generating a new token and writing it in .env.
How can I avoid this manual step?

PHP 7.1 support?

When I do composer require spatie/flysystem-dropbox in my project, I get the following error:

Using version ^1.0 for spatie/flysystem-dropbox
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - This package requires php ~7.0.0 but your PHP version (7.1.8) does not satisfy that requirement.


Installation failed, reverting ./composer.json to its original content.

Ampersand in Directory or Filname

Hi

I created a disk to access Dropbox and it works like a dream ..... Thanks for the great API

However, I have just found that is a Directory or File name includes an Ampersand (&) the path gets truncated ..... Please point me in the right direction

image

Regards

Arnold Paikin

The Dropbox API v2 does not support mimetypes

Hi,

First, thanks for your work on this piece of software.

I am using it with Laravel 5.4 as provider for flysystem, included to elFinder.

Found a weird issue, not sure it is related to your script but maybe you found this before. I can see the folders, but then I cannot access folders with files:

2017-11-18 002318

Any idea? Thanks.

Endless Loop for listContents

The Dropbox-API seems to have a bug where the listContents function in DropboxAdapter:175 gets into an endless loop for some folders.

The returned entries become at some point only 1 entry which is the $location itself but the index "has_more" still is true.

This happens in our company for only one specific folder. The function and API call for other folders behaves as expected.

As this is a quite random behavior I haven't encountered anywhere else, I thought I let you know.

Maybe someone has the same problem. Maybe someone knows whats going on. Maybe its my fault. I don't know.

Any input as to how to go about it is welcome.

Could not connect to disk dropbox because

I'm using laravel 5.4.24. I try to use laravel-backup with dropbox everything i did as mention in documentation i created DropboxServiceProvider by and install "spatie/flysystem-dropbox" but when i try clean disk its throwing errors here is full stack
2
thanks

could not list/get subfolders

Could not list subfolders:

$client = $this->getContainer()->get('dropbox.client');
$adapter = new DropboxAdapter($client);
$flysystem = new Filesystem($adapter);

$folders = $flysystem->listContents('FOO');
dump($folders);

produces:

array:9 [
  0 => array:5 [
    "path" => "FOO/BAR"
    "type" => "dir"
    "dirname" => "FOO"
    "basename" => "BAR"
    "filename" => "BAR"
  ]
  1 => array:5 [
    "path" => "FOO/BAZ"
    "type" => "dir"
    "dirname" => "FOO"
    "basename" => "BAZ"
    "filename" => "BAZ"
  ]

the next part should show the content of FOO/BAR:

$files = $flysystem->listContents($folders[0]['path']);

but this returns an empty array. When i switch to a local adapter, my code is working...
any ideas?

When I use this:

$client = $this->getContainer()->get('dropbox.client');
$adapter = new DropboxAdapter($client);
$flysystem = new Filesystem($adapter);

$folders = $flysystem->listContents('FOO/BAR');

I get the following error message:
screenshot 2017-06-19 15 27 07

get link

How can I get link to uploaded file on dropbox

how can generate view link which i have to stored in database?

i just install this package and i successfully able to upload image in my dropbox app problem is what should i store image url in databse when i try to reutn $path i got "avatars/X4caB0wH9VwDuOvVP1cdkfdDKX52VzfV8igdCd7c.png"
here is my controller method

       $path = $request->file('avatar')->store('avatars','dropbox');
       return $path; 

SSL certificate problem

Hi! ๐Ÿ‘‹

As always, another wonderful package from Spatie.

I thought I'd write up the following issue to help anyone who encounters it too.

While trying to get the package up and running on my local machine, on calling the put() method, the following exception was being thrown:

GuzzleHttp\Exception\RequestException with message 'cURL error 60: SSL certificate problem: Invalid certificate chain (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)'

To work around the exception, in DropboxServiceProvider, I simply instantiated and passed through my own GuzzleHttp\Client dependency with verify request option set to false:

<?php

namespace App\Providers;

use Storage;
use GuzzleHttp\Client as GuzzleClient;
use League\Flysystem\Filesystem;
use Spatie\Dropbox\Client as DropboxClient;
use Illuminate\Support\ServiceProvider;
use Spatie\FlysystemDropbox\DropboxAdapter;

class DropboxServiceProvider extends ServiceProvider
{
    /**
     * Perform post-registration booting of services.
     */
    public function boot()
    {
        Storage::extend('dropbox', function ($app, $config) {

            $accessToken = $config['accessToken'];

            $guzzleClient = new GuzzleClient([
                'headers' => [
                    'Authorization' => "Bearer {$accessToken}",
                ],
                'verify' => false,
            ]);

            $client = new DropboxClient($accessToken, $guzzleClient);

            return new Filesystem(new DropboxAdapter($client));

        });
    }

    /**
     * Register bindings in the container.
     */
    public function register() {}
}

Note: Guzzle's documentation mentions disabling certificate verification (setting the verify request option to false) is insecure, and thus, should probably be used with caution.

Hope this information helps someone else down the track.

Cheers!

Add compatibility for Flysystem 3

Flysystem 3 is available since almost 1 year. Currently there is no compatible Dropbox adapter for this. Could you add support for this? Actually it does not look to be that complicated according to the release blog post and the update instructions

Actually it says

Since V2, V3 has been released which is backwards compatible from a consumption point of view, but it has a BC break for custom adapter implementations.

Don't know how much work this would mean...

Updated to Laravel 9: Argument #1 ($disk) must be of type ?Illuminate\Contracts\Filesystem\Filesystem, League\Flysystem\Filesystem given,

I updated my Laravel but I get the error when I try to backup.

production.ERROR: Spatie\Backup\BackupDestination\BackupDestination::__construct(): Argument #1 ($disk) must be of type ?Illuminate\Contracts\Filesystem\Filesystem, League\Flysystem\Filesystem given, called in /var/www/mywebsite-staging/releases/12/vendor/spatie/laravel-backup/src/BackupDestination/BackupDestination.php on line 60 {"exception":"[object] (TypeError(code: 0): Spatie\\Backup\\BackupDestination\\BackupDestination::__construct(): Argument #1 ($disk) must be of type ?Illuminate\\Contracts\\Filesystem\\Filesystem, League\\Flysystem\\Filesystem given, called in /var/www/mywebsite-staging/releases/12/vendor/spatie/laravel-backup/src/BackupDestination/BackupDestination.php on line 60 at /var/www/mywebsite-staging/releases/12/vendor/spatie/laravel-backup/src/BackupDestination/BackupDestination.php:23)
[stacktrace]
#0 /var/www/mywebsite-staging/releases/12/vendor/spatie/laravel-backup/src/BackupDestination/BackupDestination.php(60): Spatie\\Backup\\BackupDestination\\BackupDestination->__construct()
#1 /var/www/mywebsite-staging/releases/12/vendor/spatie/laravel-backup/src/BackupDestination/BackupDestinationFactory.php(12): Spatie\\Backup\\BackupDestination\\BackupDestination::create()
#2 [internal function]: Spatie\\Backup\\BackupDestination\\BackupDestinationFactory::Spatie\\Backup\\BackupDestination\\{closure}()
#3 /var/www/mywebsite-staging/releases/12/vendor/laravel/framework/src/Illuminate/Collections/Collection.php(721): array_map()
#4 /var/www/mywebsite-staging/releases/12/vendor/spatie/laravel-backup/src/BackupDestination/BackupDestinationFactory.php(12): Illuminate\\Support\\Collection->map()
#5 /var/www/mywebsite-staging/releases/12/vendor/spatie/laravel-backup/src/Tasks/Backup/BackupJobFactory.php(16): Spatie\\Backup\\BackupDestination\\BackupDestinationFactory::createFromArray()

I'm using a DropboxServiceProvider to extend the Storage for Dropbox

<?php

namespace App\Providers;

use Illuminate\Support\Facades\Storage;
use Illuminate\Support\ServiceProvider;
use League\Flysystem\Filesystem;
use Spatie\Dropbox\Client as DropboxClient;
use Spatie\FlysystemDropbox\DropboxAdapter;

class DropboxServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        Storage::extend('dropbox', function ($app, $config) {
            $client = new DropboxClient(
                $config['authorization_token']
            );

            return new Filesystem(new DropboxAdapter($client), ['case_sensitive' => false]);
        });
    }
}

Besides that I saw that another person has the issue:
#83

Thank you <3

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.