Skip to content

Commit

Permalink
Allow deleting files by bucket name and file name
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris White committed Feb 18, 2016
1 parent b7b0117 commit 942fbcc
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@ public function listFiles(array $options)

/**
* Returns a single File object representing a file stored on B2.
* @TODO: allow specifying file via its name and bucket.
*
* @param array $options
* @return File
Expand Down Expand Up @@ -332,7 +331,6 @@ public function getFile(array $options)

/**
* Deletes the file identified by ID from Backblaze B2.
* @TODO: allow deleting a file via its name and bucket.
*
* @param array $options
* @return bool
Expand All @@ -345,6 +343,12 @@ public function deleteFile(array $options)
$options['FileName'] = $file->getName();
}

if (!isset($options['FileId']) && isset($options['BucketName']) && isset($options['FileName'])) {
$file = $this->getFile($options);

$options['FileId'] = $file->getId();
}

$this->client->request('POST', $this->apiUrl.'/b2_delete_file_version', [
'headers' => [
'Authorization' => $this->authToken
Expand Down

0 comments on commit 942fbcc

Please sign in to comment.