spatie / flysystem-dropbox Goto Github PK
View Code? Open in Web Editor NEWA flysystem driver for Dropbox that uses the v2 API
License: MIT License
A flysystem driver for Dropbox that uses the v2 API
License: MIT License
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.
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
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.
Hello,
I am currently exploring your library by discovering step by step the different methods to apply to my project.
I have a problem with getTemporaryLink.
Thank you for your work.
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
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');
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()
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.
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...
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.
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:
Any idea? Thanks.
HI!
This bug seems similar to: https://github.com/thephpleague/flysystem-dropbox/issues/3
Dropbox API v1 and v2 are both case-insensitive: https://www.dropboxforum.com/t5/API-support/Case-Sensitivity-in-API-2/m-p/191279#M8337
If I try to fetch "Test1/Test2/toto.txt" that returns nothing, because Dropbox returns "test1/Test2/toto.txt" and does not match.
Can we do somthing for that?
Thanks! :)
Hi, thank you for the adapter. It has been very useful.
Dropbox is ending long-lived tokens on September 30th, 2021 - it seems the current code only accomodates long-lived tokens. Is there anyone currently working toward incorporating this new change? If not, I will start.
https://dropbox.tech/developers/migrating-app-permissions-and-access-tokens
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
Documentation says there are two ways to create a client.
$client = new DropboxClient($config['authorization_token']);
with token$client = new DropboxClient([$config['appKey'],$config['appSecret']]);
with App key and App secretFirst 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?
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.
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 !
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
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!
Hi,
Thank' for this package!
I found a mistake:
I try to download file using his Dropbox ID (id:xxx
)
File not found at path: id:xxx
After investigation I think the mistake is on applyPathPrefix method.
After prefix apply, API call param is /id:
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);
}
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 ?
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
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?
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
thanks
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,…},…]
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.
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.
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);
}
each user has it's dropbox token in db , and I need to set the token before i try to use the disk,
Question: how can I change the token so I could write in each users's folders?
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
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.
How can I get link to uploaded file on dropbox
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.
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
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;
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');
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.