Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename Directory using laravel #126

Open
monika-sha90 opened this issue Jun 20, 2024 · 5 comments · May be fixed by #127
Open

Rename Directory using laravel #126

monika-sha90 opened this issue Jun 20, 2024 · 5 comments · May be fixed by #127

Comments

@monika-sha90
Copy link

Rename directory using directory id in laravel.

Storage::disk('google');
using this command

@angeljqv
Copy link

angeljqv commented Jun 20, 2024

You could try move
laravel-google-drive-ext-demo/routes/web.php#L146
But with "directory id" maybe nao-pon/flysystem-google-drive,
everything is easier with virtual paths

Also if there is a bug, you could make a PR with the fix

@erikn69 erikn69 linked a pull request Jun 20, 2024 that will close this issue
@erikn69
Copy link
Contributor

erikn69 commented Jun 20, 2024

Hi, could you test #127

@monika-sha90
Copy link
Author

No its not working.
I am using this to rename directory or folder or file
Storage::disk('google')->move('1eBA6ICIYymKpreWwoQoUfARCU_5Ovqkd','test');

@monika-sha90
Copy link
Author

These are working in laravel--
$createDirectory = Storage::disk('google')->makeDirectory('Directory1');
$createSubDirectory = Storage::disk('google')->makeDirectory('1mRjuzvIFtATv4j7ky1GcKYLO9mihWq5n/task1');
$deleteDirectory = Storage::disk('google')->deleteDirectory('1Mzhig8KeIkhQIIay63ApfUKDUg_Be0LC');// folder id

@erikn69
Copy link
Contributor

erikn69 commented Jun 21, 2024

No its not working.

you did something wrong, I have created the branch laravel-google-drive-ext-demo/tree/no_virtual_paths

And the demo it's working laravel-google-drive-ext-demo/routes/web.php#L201-L220

$directoryName = 'test';

// First we need to create a directory to rename
Storage::disk('google')->makeDirectory($directoryName);

// Now find that directory and use its ID (path) to rename it
$dir = collect(Storage::disk('google')->listContents('/', false))
    ->first(fn (\League\Flysystem\StorageAttributes $file) =>
        $file->type() === 'dir' && $file->extraMetadata()['name'] === $directoryName
    ); // there can be duplicate file names!

if (! $dir) {
    return 'Directory "'.$directoryName.'" does not exist!';
}

Storage::disk('google')->move($dir->path(), 'new-test');

RESULT:
image

you know how to use another branch in the vendor?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants