You are here

public function AmazonS3StreamWrapper::unlink in AmazonS3 7

Support for unlink().

Parameters

string $uri: A string containing the uri to the resource to delete.

Return value

bool TRUE if resource was successfully deleted.

Overrides StreamWrapperInterface::unlink

See also

http://php.net/manual/en/streamwrapper.unlink.php

1 call to AmazonS3StreamWrapper::unlink()
AmazonS3StreamWrapper::rename in ./AmazonS3StreamWrapper.inc
Support for rename().

File

./AmazonS3StreamWrapper.inc, line 686
Drupal stream wrapper implementation for Amazon S3

Class

AmazonS3StreamWrapper
@file Drupal stream wrapper implementation for Amazon S3

Code

public function unlink($uri) {
  $this
    ->assertConstructorCalled();
  try {
    $response = $this
      ->getS3()
      ->delete_object($this->bucket, $this
      ->getLocalPath($uri));
    if ($response
      ->isOK()) {

      // Delete from cache.
      db_delete('amazons3_file')
        ->condition('uri', $uri)
        ->execute();
      return TRUE;
    }
  } catch (Exception $e) {
    watchdog('amazons3', 'Unable to delete @uri', array(
      '@uri' => $uri,
    ), WATCHDOG_NOTICE);
  }
  return FALSE;
}