/**
     * {@inheritDoc}
     */
    public function remove(array $paths, array $filters)
    {
        if (empty($paths) && empty($filters)) {
            return;
        }

        if (empty($paths)) {
            if (!$this->storage->delete_all_objects($this->bucket, sprintf('/%s/i', implode('|', $filters)))) {
                $this->logError('The objects could not be deleted from Amazon S3.', array(
                    'filters'      => implode(', ', $filters),
                    'bucket'      => $this->bucket,
                ));
            }

            return;
        }

        foreach ($filters as $filter) {
            foreach ($paths as $path) {
                $objectPath = $this->getObjectPath($path, $filter);
                if (!$this->objectExists($objectPath)) {
                    continue;
                }

                if (!$this->storage->delete_object($this->bucket, $objectPath)->isOK()) {
                    $this->logError('The objects could not be deleted from Amazon S3.', array(
                        'filter'      => $filter,
                        'bucket'      => $this->bucket,
                        'path'        => $path,
                    ));
                }
            }
        }
    }
Пример #2
0
 public function tearDown()
 {
     if ($this->instance) {
         $s3 = new AmazonS3(array('key' => $this->config['amazons3']['key'], 'secret' => $this->config['amazons3']['secret']));
         if ($s3->delete_all_objects($this->id)) {
             $s3->delete_bucket($this->id);
         }
     }
 }