/** * Override the S3 Put Object arguments * * @return bool */ public function stream_flush() { // Set the ACL as public by default $this->params['ACL'] = Amazon_S3_And_CloudFront::DEFAULT_ACL; $this->params = apply_filters('wpos3_stream_flush_params', $this->params); return parent::stream_flush(); }
/** * @param string $path * @param string $mode * @param int $options * @param string $opened_path * * @return bool */ public function stream_open($path, $mode, $options, &$opened_path) { $result = parent::stream_open($path, $mode, $options, $opened_path); if (!$result) { return $result; } $mode_short = substr($mode, 0, 1); if ($mode_short === 'r' || $mode_short === 'a') { return $result; } /** * As we open a temp stream, we don't actually know if we have writing ability yet. * This means functions like copy() will not fail correctly, as the write to s3 * is only attemped on stream_flush() which is too late to report to copy() * et al that the write has failed. * * As a work around, we attempt to write an empty object. */ try { $p = $this->params; $p['Body'] = ''; static::$client->putObject($p); } catch (\Exception $e) { return $this->triggerError($e->getMessage()); } return $result; }