本文整理汇总了PHP中S3::putObjectString方法的典型用法代码示例。如果您正苦于以下问题:PHP S3::putObjectString方法的具体用法?PHP S3::putObjectString怎么用?PHP S3::putObjectString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类S3
的用法示例。
在下文中一共展示了S3::putObjectString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test
/**
* Tests S3
*
* @param string $error
* @return boolean
*/
function test(&$error)
{
if (!parent::test($error)) {
return false;
}
$string = 'test_s3_' . md5(time());
if (!$this->_init($error)) {
return false;
}
$this->_set_error_handler();
$buckets = @$this->_s3->listBuckets();
if ($buckets === false) {
$error = sprintf('Unable to list buckets (%s).', $this->_get_last_error());
$this->_restore_error_handler();
return false;
}
if (!in_array($this->_config['bucket'], (array) $buckets)) {
$error = sprintf('Bucket doesn\'t exist: %s.', $this->_config['bucket']);
$this->_restore_error_handler();
return false;
}
if (!@$this->_s3->putObjectString($string, $this->_config['bucket'], $string, S3::ACL_PUBLIC_READ)) {
$error = sprintf('Unable to put object (%s).', $this->_get_last_error());
$this->_restore_error_handler();
return false;
}
if (!($object = @$this->_s3->getObject($this->_config['bucket'], $string))) {
$error = sprintf('Unable to get object (%s).', $this->_get_last_error());
$this->_restore_error_handler();
return false;
}
if ($object->body != $string) {
$error = 'Objects are not equal.';
@$this->_s3->deleteObject($this->_config['bucket'], $string);
$this->_restore_error_handler();
return false;
}
if (!@$this->_s3->deleteObject($this->_config['bucket'], $string)) {
$error = sprintf('Unable to delete object (%s).', $this->_get_last_error());
$this->_restore_error_handler();
return false;
}
$this->_restore_error_handler();
return true;
}
示例2: test
/**
* Tests S3
*
* @param string $error
* @return boolean
*/
function test(&$error)
{
$string = 'test_s3_' . md5(time());
if (!$this->_init($error)) {
return false;
}
$domain = $this->get_domain();
if (!$domain) {
$error = 'Empty domain.';
return false;
}
if (gethostbyname($domain) == $domain) {
$error = sprintf('Unable to resolve domain: %s.', $domain);
return false;
}
$buckets = @$this->_s3->listBuckets();
if (!$buckets) {
$error = 'Unable to list buckets (check your credentials).';
return false;
}
if (!in_array($this->_config['bucket'], (array) $buckets)) {
$error = sprintf('Bucket doesn\'t exist: %s', $this->_config['bucket']);
return false;
}
if (!@$this->_s3->putObjectString($string, $this->_config['bucket'], $string, S3::ACL_PUBLIC_READ)) {
$error = 'Unable to put object.';
return false;
}
if (!($object = @$this->_s3->getObject($this->_config['bucket'], $string))) {
$error = 'Unable to get object.';
return false;
}
if ($object->body != $string) {
@$this->_s3->deleteObject($this->_config['bucket'], $string);
$error = 'Objects are not equal.';
return false;
}
if (!@$this->_s3->deleteObject($this->_config['bucket'], $string)) {
$error = 'Unable to delete object.';
return false;
}
return true;
}
示例3: validate_access_details
static function validate_access_details($access_key, $secret_key, $bucket_name)
{
require_once MODPATH . "aws_s3/lib/s3.php";
S3::setAuth($access_key, $secret_key);
S3::$useSSL = false;
$success_test = S3::putObjectString((string) time(), $bucket_name, ".s3_test");
if ($success_test) {
S3::deleteObject($bucket_name, ".s3_test");
}
return $success_test;
}