Example #1
0
 /**
  * @param array $files
  */
 public function bulkDelete(array $files)
 {
     $objects = [];
     foreach ($files as $filePath) {
         $objects[] = ['Key' => Utils::normalizePath($this->relativePath . '/' . $filePath)];
     }
     $this->s3Client->deleteObjects(['Bucket' => $this->basePath, 'Delete' => ['Objects' => $objects]]);
 }
Example #2
0
 /**
  * @param $files
  * @return mixed
  */
 public function delete($files)
 {
     $result['status'] = false;
     $objects = [];
     foreach ($files as $fileKey) {
         $objects[] = $fileKey;
     }
     try {
         $deleteResult = $this->s3->deleteObjects(['Bucket' => $this->bucket, 'Delete' => ['Objects' => $objects]]);
         $result['status'] = true;
         $result['data'] = $deleteResult;
     } catch (S3Exception $e) {
         echo $e . "\nThere was an error uploading the file.\n";
     }
     return $result;
 }
Example #3
0
 public function rmdir($path)
 {
     $path = $this->normalizePath($path);
     if (!$this->file_exists($path)) {
         return false;
     }
     // Since there are no real directories on S3, we need
     // to delete all objects prefixed with the path.
     $objects = $this->connection->listObjects(array('Bucket' => $this->bucket, 'Prefix' => $path . '/'));
     try {
         $result = $this->connection->deleteObjects(array('Bucket' => $this->bucket, 'Objects' => $objects['Contents']));
         $this->testTimeout();
     } catch (S3Exception $e) {
         \OCP\Util::writeLog('files_external', $e->getMessage(), \OCP\Util::ERROR);
         return false;
     }
     return true;
 }
Example #4
0
 /**
  * Remove an attached file.
  *
  * @param array $filePaths
  */
 public function remove(array $filePaths)
 {
     if ($filePaths) {
         $this->s3Client->deleteObjects(['Bucket' => $this->attachedFile->s3_object_config['Bucket'], 'Delete' => ['Objects' => $this->getKeys($filePaths)]]);
     }
 }
Example #5
-1
 /**
  * This operation enables you to delete multiple objects from a bucket using a single HTTP request.
  * You may specify up to 1000 keys.
  *
  * @param string $bucket
  * @param array  $objects
  *
  * @return mixed
  */
 public function deleteObjects($bucket, array $objects)
 {
     $params = ['Bucket' => $bucket, 'Objects' => []];
     foreach ($objects as $object) {
         $objects[] = ['Key' => $object];
     }
     return $this->instance->deleteObjects($params);
 }