get_s3client() public method

Get the S3 client
public get_s3client ( boolean | string $region = false, boolean $force = false ) : Aws\S3\S3Client
$region boolean | string specify region to client for signature
$force boolean force return of new S3 client when swapping regions
return Aws\S3\S3Client
コード例 #1
0
 /**
  * Download a file from S3 if the file does not exist locally and places it where
  * the attachment's file should be.
  *
  * @param array  $s3_object
  * @param string $file
  *
  * @return string|bool File if downloaded, false on failure
  */
 protected function copy_s3_file_to_server($s3_object, $file)
 {
     try {
         $this->as3cf->get_s3client($s3_object['region'], true)->getObject(array('Bucket' => $s3_object['bucket'], 'Key' => $s3_object['key'], 'SaveAs' => $file));
     } catch (Exception $e) {
         error_log(sprintf(__('There was an error attempting to download the file %s from S3: %s', 'as3cf'), $s3_object['key'], $e->getMessage()));
         return false;
     }
     return $file;
 }
コード例 #2
0
 /**
  * Register stream wrappers per region
  *
  * @param string $region
  *
  * @return mixed
  */
 protected function register_stream_wrapper($region)
 {
     $stored_region = '' === $region ? Amazon_S3_And_CloudFront::DEFAULT_REGION : $region;
     if (in_array($stored_region, self::$stream_wrappers)) {
         return;
     }
     $client = $this->as3cf->get_s3client($region, true);
     $protocol = $this->get_stream_wrapper_protocol($region);
     // Register the region specific S3 stream wrapper to be used by plugins
     AS3CF_Stream_Wrapper::register($client, $protocol);
     self::$stream_wrappers[] = $stored_region;
 }