You are here

public function S3fsStreamWrapper::waitUntilFileExists in S3 File System 7.2

Same name and namespace in other branches
  1. 7.3 S3fsStreamWrapper.inc \S3fsStreamWrapper::waitUntilFileExists()
  2. 7 S3fsStreamWrapper.inc \S3fsStreamWrapper::waitUntilFileExists()

Wait for the specified file to exist in the bucket.

Parameters

string $uri: The URI of the file.

Return value

bool Returns TRUE once the waiting finishes, or FALSE if the file does not begin to exist within 10 seconds.

2 calls to S3fsStreamWrapper::waitUntilFileExists()
S3fsStreamWrapper::rename in ./S3fsStreamWrapper.inc
Support for rename().
S3fsStreamWrapper::writeUriToCache in ./S3fsStreamWrapper.inc
Write the file at the given URI into the metadata cache.

File

./S3fsStreamWrapper.inc, line 491
Drupal stream wrapper implementation for S3 File System.

Class

S3fsStreamWrapper
The stream wrapper class.

Code

public function waitUntilFileExists($uri) {
  $wait_params = $this
    ->_get_params($uri);

  // Retry ten times, once every second.
  $wait_params['waiter.max_attempts'] = 10;
  $wait_params['waiter.interval'] = 1;
  try {
    $this->s3
      ->waitUntilObjectExists($wait_params);
  } catch (Aws\Common\Exception\RuntimeException $e) {
    return FALSE;
  }
  return TRUE;
}