Skip to content
This repository has been archived by the owner on Jul 17, 2024. It is now read-only.

Can't Delete Directory Laravel 5.4 #16

Closed
loooping-old opened this issue Jul 27, 2017 · 3 comments
Closed

Can't Delete Directory Laravel 5.4 #16

loooping-old opened this issue Jul 27, 2017 · 3 comments

Comments

@loooping-old
Copy link

loooping-old commented Jul 27, 2017

I try delete a sub-directory of my Google Cloud Storage, but give me a error.

$disk = Storage::disk('gcs');
$dir = 'directory/2/otherdir/3'; <- i need delete this directory

$disk->deleteDirectory($dir);

I HAVE THIS RETURN

[19:35:45] LOG.error: Google\Cloud\Core\Exception\NotFoundException: {
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "notFound",
    "message": "Not Found"
   }
  ],
  "code": 404,
  "message": "Not Found"
 }
}
 in /Users/pablo/Sistemas/clientsystem/vendor/google/cloud/src/Core/RequestWrapper.php:241
@BradWhittington
Copy link

GCS doesn't have a concept of directories, you have to iterate and remove each object - https://stackoverflow.com/questions/5630093/how-to-delete-folder-with-files-using-google-storage-rest-api

@loooping-old
Copy link
Author

loooping-old commented Jul 28, 2017

I found solution for this case

<?php
if( $disk->files($dir) ){ // verify if exists files inside object
  $disk->delete($disk->files($dir)); //delete all files and object in GCS
}
?>

Thanks.

@TzviCons
Copy link

TzviCons commented Jul 4, 2018

Hi,

I'm having a similar issue and am wondering why Superbalist implemented the deleteDir() method as a wrapper around the delete() method. It sounds like the deleteDir() should have looped through the directories' contents first!

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

No branches or pull requests

3 participants