oneduo / nova-file-manager

The most advanced File Manager for Laravel Nova, feature rich and robust build.
https://oneduo.github.io/nova-file-manager/
MIT License
142 stars 38 forks source link

Digital Ocean Spaces #100

Closed ChrisWillerton closed 2 years ago

ChrisWillerton commented 2 years ago

When using Digital Ocean Spaces (which uses the S3 driver) I can upload an initial file or folder, but after that if I try to add another I get an error saying that the selected path already exists. I have triple checked and in each test the folder or file does not exist.

My Digital Ocean disk config is as below:

'digitalocean' => [ 'driver' => 's3', 'key' => env('DIGITALOCEAN_SPACES_KEY'), 'secret' => env('DIGITALOCEAN_SPACES_SECRET'), 'endpoint' => env('DIGITALOCEAN_SPACES_ENDPOINT'), 'region' => env('DIGITALOCEAN_SPACES_REGION'), 'bucket' => env('DIGITALOCEAN_SPACES_BUCKET'), 'url' => env('DIGITALOCEAN_SPACES_URL'), 'visibility' => 'public', 'use_path_style_endpoint' => false, 'throw' => false, ],

Screenshots First upload or folder creation works ok:

image

Second attempt returns error:

image

Screenshot of the spaces view in Digital Ocean to show only one folder present:

image

I'm using Laravel ~9.0, Nova ~4.0 and the file manager package version is ^0.7.3

I'm on MacOS in Google Chrome.

I apologise if this is a configuration error on my part, but I have checked things over and over. Also, because it allows an initial file upload or creation it makes me think that the configuration is probably correct.

Thanks for the fantastic work on this package. Do let me know if I can provide anymore useful info.

Chris

mikaelpopowicz commented 2 years ago

Hi @ChrisWillerton

Thank you for your kind words.

Unfortunately, I'm not able to reproduce your issue. I tried with a fresh Digital Ocean space and it works well.

I used your configuration example :

<?php

// config/filesystems.php

return [
    //
    'disks' => [
        'digitalocean' => [
            'driver' => 's3',
            'key' => env('DIGITALOCEAN_SPACES_KEY'),
            'secret' => env('DIGITALOCEAN_SPACES_SECRET'),
            'region' => env('DIGITALOCEAN_SPACES_REGION'),
            'bucket' => env('DIGITALOCEAN_SPACES_BUCKET'),
            'url' => env('DIGITALOCEAN_SPACES_URL'),
            'endpoint' => env('DIGITALOCEAN_SPACES_ENDPOINT'),
            'visibility' => 'public',
            'use_path_style_endpoint' => env('DIGITALOCEAN_SPACES_USE_PATH_STYLE_ENDPOINT', false),
            'throw' => false,
        ],
    ],
];
<?php

// config/nova-file-manager.php

return [
    //
    'available_disks' => [
        'public',
        'digitalocean',
    ],
];
# .env

DIGITALOCEAN_SPACES_KEY=# the space's access key `key`
DIGITALOCEAN_SPACES_SECRET=# the space's access key `secret`
DIGITALOCEAN_SPACES_REGION=# the space's region you defined at creation
DIGITALOCEAN_SPACES_BUCKET=# the space's name
DIGITALOCEAN_SPACES_ENDPOINT="https://${DIGITALOCEAN_SPACES_REGION}.digitaloceanspaces.com"
DIGITALOCEAN_SPACES_USE_PATH_STYLE_ENDPOINT=false

NOVA_FILE_MANAGER_URL_SIGNING_ENABLED=true

Notice I don't set DIGITALOCEAN_SPACES_URL.

Do you mind to test your filesystem with the Storage facade ?

\Illuminate\Support\Facades\Storage::disk('digitalocean')->missing('New folder with different name');
ChrisWillerton commented 2 years ago

Hi @mikaelpopowicz

Thanks for taking the time to look into this and come back to me.

I've mimicked your setup exactly - including not setting DIGITALOCEAN_SPACES_URL but unfortunately I am still having the same issue.

I've also tested uploads to the space with Nova's default file upload and this is working ok.

I've tested the filesystem as you mentioned using Tinker. The output is below:

image

Do you have any settings different to mine in Digital Ocean itself?

image

Thanks again,

Chris

mikaelpopowicz commented 2 years ago

Hi @ChrisWillerton

As you show me

\Illuminate\Support\Facades\Storage::disk('digitalocean')->missing('New folder with different name');

returns false instead of true.

It seems to be related to your Laravel filesystem dependencies. Did you require "league/flysystem-aws-s3-v3": "^3.0" ? What is your aws/aws-sdk-php version ?

composer show aws/aws-sdk-php | grep version

PS: I have the same space settings.

ChrisWillerton commented 2 years ago

Hi @mikaelpopowicz

In my composer.json I have this for the flysystem package

`"league/flysystem-aws-s3-v3": "^3.10",``

For my aws/aws-sdk-php version, I ran your command and have:

versions : * 3.243.1

Thanks for confirming it's the same space settings.

Chris

mikaelpopowicz commented 2 years ago

This relates to https://github.com/aws/aws-sdk-php/issues/2558 which has been fixed since https://github.com/aws/aws-sdk-php/releases/tag/3.244.0.

You may update aws/aws-sdk-php to fix your issue.

ChrisWillerton commented 2 years ago

@mikaelpopowicz Everything is now working as expected.

Thanks so much for your time looking into this, and apologies the issue was with a third party.