本文整理汇总了PHP中S3::setEndpoint方法的典型用法代码示例。如果您正苦于以下问题:PHP S3::setEndpoint方法的具体用法?PHP S3::setEndpoint怎么用?PHP S3::setEndpoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类S3
的用法示例。
在下文中一共展示了S3::setEndpoint方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _prepareForRequests
/**
* Prepare the S3 connection for requests to this bucket.
*
* @param $settings
*/
private function _prepareForRequests($settings = null)
{
if (is_null($settings)) {
$settings = $this->getSettings();
}
if (is_null($this->_s3)) {
$this->_s3 = new \S3($settings->keyId, $settings->secret);
}
\S3::setAuth($settings->keyId, $settings->secret);
$this->_s3->setEndpoint(static::getEndpointByLocation($settings->location));
}
示例2: _getS3
/**
* Returns a fresh S3 instance
*/
private function _getS3($cfg)
{
$s3 = new S3($cfg['accesskey'], $cfg['secretkey']);
if (!empty($cfg['endpoint'])) {
$s3->setEndpoint($cfg['endpoint']);
}
return $s3;
}
示例3: updateUserImage
public static function updateUserImage($userId)
{
$result = new FunctionResult();
$result->success = false;
if (!empty($userId)) {
$user = GameUsers::getGameUserById($userId);
if (!empty($user)) {
$tmpImgPath = UserProfileImageUtils::downloadFBProfileImage($user->facebookId);
$profileImageUrl = null;
if (!empty($tmpImgPath)) {
try {
$s3 = new S3(AWS_API_KEY, AWS_SECRET_KEY);
$s3->setEndpoint(AWS_S3_ENDPOINT);
$imageName = "pi_" . $userId . ".png";
$s3Name = "profile.images/" . $userId . "/" . $imageName;
$res = $s3->putObjectFile($tmpImgPath, AWS_S3_BUCKET, $s3Name, S3::ACL_PUBLIC_READ);
if ($res) {
$profileImageUrl = 'http://' . AWS_S3_BUCKET . '.s3.amazonaws.com/' . $s3Name;
try {
unlink($tmpImgPath);
} catch (Exception $exc) {
error_log($exc->getTraceAsString());
}
} else {
$result->result = json_encode($res);
}
} catch (Exception $exc) {
$result->result = $exc->getTraceAsString();
}
} else {
$profileImageUrl = USER_DEFAULT_IMAGE_URL;
}
if (!empty($profileImageUrl)) {
$user->setProfilePicture($profileImageUrl);
try {
$user->updateToDatabase(DBUtils::getConnection());
$result->success = true;
$result->result = null;
} catch (Exception $exc) {
$result->result = $exc->getTraceAsString();
}
}
} else {
$result->result = "user not found";
}
} else {
$result->result = "user id empty";
}
return $result;
}
示例4: __construct
/**
* component constructor - set up local vars based on settings array in controller
*/
public function __construct(ComponentCollection $collection, $settings = array())
{
parent::__construct($collection, $settings);
// setup the instance vars
if (!empty($settings)) {
foreach ($settings as $var => $val) {
$this->{$var} = $val;
}
} else {
if ($config = Configure::read('CakeS3')) {
foreach ($config as $var => $val) {
$this->{$var} = $val;
}
}
}
if (empty($this->s3Key) || empty($this->s3Secret)) {
throw new Exception('S3 Keys not set up. Unable to connect');
}
S3::setAuth($this->s3Key, $this->s3Secret);
S3::setEndpoint($this->endpoint);
}
示例5: VALUES
//.........这里部分代码省略.........
$out = curl_exec($curl);
$error = curl_error($curl);
if ($error != '') {
return $this->EE->output->show_user_error('general', array($this->EE->lang->line('curl_error') . $error));
}
$size = curl_getinfo($curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD);
curl_close($curl);
$memory = memory_get_usage(true);
if ($size > $memory * 3 / 4) {
$use_curl = false;
}
}
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public", FALSE);
header("Content-Description: File Transfer");
header("Content-Type: " . $type);
header("Accept-Ranges: bytes");
if ($inline == true) {
header("Content-Disposition: inline; filename=\"" . $filename . "\";");
} else {
header("Content-Disposition: attachment; filename=\"" . $filename . "\";");
}
header("Content-Transfer-Encoding: binary");
if ($use_curl == true) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, str_replace('/', '/', $url));
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
if (ini_get('open_basedir') == '' && ini_get('safe_mode' == 'Off')) {
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
}
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_SSLVERSION, 3);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0');
$out = curl_exec($curl);
curl_close($curl);
echo $out;
} else {
$fp = fopen(str_replace('/', '/', $url), "rb");
while (!feof($fp)) {
echo fread($fp, 4096);
flush();
}
fclose($fp);
}
break;
case 's3':
case 'S3':
require_once PATH_THIRD . "protected_links/storage_api/amazon/S3.php";
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public", FALSE);
header("Content-Description: File Transfer");
header("Content-Type: " . $type);
header("Accept-Ranges: bytes");
if ($inline == true) {
header("Content-Disposition: inline; filename=\"" . $filename . "\";");
} else {
header("Content-Disposition: attachment; filename=\"" . $filename . "\";");
}
header("Content-Transfer-Encoding: binary");
$s3 = new S3($this->settings['s3_key_id'], $this->settings['s3_key_value']);
if ($endpoint != '') {
$s3->setEndpoint($endpoint);
}
$fp = fopen("php://output", "wb");
$s3->getObject("{$container}", $url, $fp);
fclose($fp);
break;
case 'rackspace':
require_once PATH_THIRD . "protected_links/storage_api/rackspace/cloudfiles.php";
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public", FALSE);
header("Content-Description: File Transfer");
header("Content-Type: " . $type);
header("Accept-Ranges: bytes");
if ($inline == true) {
header("Content-Disposition: inline; filename=\"" . $filename . "\";");
} else {
header("Content-Disposition: attachment; filename=\"" . $filename . "\";");
}
header("Content-Transfer-Encoding: binary");
$auth = new CF_Authentication($this->settings['rackspace_api_login'], $this->settings['rackspace_api_password']);
$auth->authenticate();
$conn = new CF_Connection($auth);
$container = $conn->get_container("{$container}");
$fp = fopen("php://output", "wb");
$url->stream($fp);
fclose($fp);
break;
}
exit;
}