public function emptyBucket()
    {

        // connect before uploading
        $connected = $this->connect();

        if (!$connected) {
            return false;
        }

        // user terminal message
        $this->console->writeln('<fg=yellow>Emptying in progress...</fg=yellow>');

        try {

            // Get the contents of the bucket for information purposes
            $contents = $this->s3_client->listObjects([
                'Bucket' => $this->getBucket(),
                'Key' => '',
            ]);

            // Check if the bucket is already empty
            if (!$contents['Contents']) {
                $this->console->writeln('<fg=green>The bucket '.$this->getBucket().' is already empty.</fg=green>');

                return true;
            }

            // Empty out the bucket
            $empty = BatchDelete::fromListObjects($this->s3_client, [
                'Bucket' => $this->getBucket(),
                'Prefix' => null,
            ]);

            $empty->delete();
        } catch (S3Exception $e) {
            $this->console->writeln('<fg=red>'.$e->getMessage().'</fg=red>');

            return false;
        }

        $this->console->writeln('<fg=green>The bucket '.$this->getBucket().' is now empty.</fg=green>');

        return true;
    }
public function emptyBucket()
    {

        // connect before uploading
        $connected = $this->connect();

        if (!$connected) {
            return false;
        }

        // user terminal message
        $this->console->writeln('<fg=yellow>Emptying in progress...</fg=yellow>');

        try {

            // Get the contents of the bucket for information purposes
            $contents = $this->s3_client->listObjects([
                'Bucket' => $this->getBucket(),
                'Key' => '',
            ]);

            // Check if the bucket is already empty
            if (!$contents['Contents']) {
                $this->console->writeln('<fg=green>The bucket '.$this->getBucket().' is already empty.</fg=green>');

                return true;
            }

            // Empty out the bucket
            $empty = BatchDelete::fromListObjects($this->s3_client, [
                'Bucket' => $this->getBucket(),
                'Prefix' => null,
            ]);

            $empty->delete();
        } catch (S3Exception $e) {
            $this->console->writeln('<fg=red>'.$e->getMessage().'</fg=red>');

            return false;
        }

        $this->console->writeln('<fg=green>The bucket '.$this->getBucket().' is now empty.</fg=green>');

        return true;
    }
public function emptyBucket ( ) { // connect before uploading $ connected = $ this -> connect ( ) ; if ( ! $ connected ) { return false ; } // user terminal message $ this -> console -> writeln ( '<fg=yellow>Emptying in progress...</fg=yellow>' ) ; try { // Get the contents of the bucket for information purposes $ contents = $ this -> s3_client -> listObjects ( [ 'Bucket' => $ this -> getBucket ( ) , 'Key' => '' , ] ) ; // Check if the bucket is already empty if ( ! $ contents [ 'Contents' ] ) { $ this -> console -> writeln ( '<fg=green>The bucket ' . $ this -> getBucket ( ) . ' is already empty.</fg=green>' ) ; return true ; } // Empty out the bucket $ empty = BatchDelete :: fromListObjects ( $ this -> s3_client , [ 'Bucket' => $ this -> getBucket ( ) , 'Prefix' => null , ] ) ; $ empty -> delete ( ) ; } catch ( S3Exception $ e ) { $ this -> console -> writeln ( '<fg=red>' . $ e -> getMessage ( ) . '</fg=red>' ) ; return false ; } $ this -> console -> writeln ( '<fg=green>The bucket ' . $ this -> getBucket ( ) . ' is now empty.</fg=green>' ) ; return true ; }
Empty bucket.

@return bool
Empty bucket .