本文整理汇总了PHP中S3::deleteObject方法的典型用法代码示例。如果您正苦于以下问题:PHP S3::deleteObject方法的具体用法?PHP S3::deleteObject怎么用?PHP S3::deleteObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类S3
的用法示例。
在下文中一共展示了S3::deleteObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleteS3File
/**
* Delete file from S3 when deleted from local disk
*
* Wordpress sometimes sends a partial path and sometimes sends an unescaped path
* (depending on the OS), so this function normalizes it and removes the object
* from the S3 bucket and returns a true absolute path to the file for `unlink()`
* to do it's job.
*
* @param string $file Some sort of path
* @return string Absolute path to file
*/
function deleteS3File($file)
{
$s3Key = get_option('s3_access_key');
$s3KeySecret = get_option('s3_access_secret');
$bucket = get_option('s3_bucket');
$S3 = new S3($s3Key, $s3KeySecret);
$path = getS3Path($file);
// delete from bucket
$S3->deleteObject($bucket, $path);
// save this image path for later cloudfront invalidation
$pathsToInvalidate[] = "/{$path}";
return $file;
}
示例2: action_delete
/**
* CRUD controller: DELETE
*/
public function action_delete()
{
if (!Core::get('name')) {
return FALSE;
}
if (core::config('image.aws_s3_active')) {
require_once Kohana::find_file('vendor', 'amazon-s3-php-class/S3', 'php');
$s3 = new S3(core::config('image.aws_access_key'), core::config('image.aws_secret_key'));
}
$image_name = Core::get('name');
$root = DOCROOT . 'images/cms/';
//root folder
if (!is_dir($root)) {
return FALSE;
} else {
//delete image
@unlink($root . $image_name);
// delete image from Amazon S3
if (core::config('image.aws_s3_active')) {
$s3->deleteObject(core::config('image.aws_s3_bucket'), 'images/cms/' . $image_name);
}
}
return TRUE;
}
示例3: delete
/**
* Delete a file from Amazon S3 or locally.
*
* @access public
* @param string $path
* @return boolean
*/
public function delete($path)
{
if ($this->s3 !== null) {
return $this->s3->deleteObject($this->s3->bucket, $this->s3->path . basename($path));
}
return $this->uploader->delete($path);
}
示例4: delete
/**
* Delete a file from Amazon S3 or locally.
*
* @access public
* @param string $path
* @return boolean
*/
public function delete($path)
{
if ($this->s3 !== null && strpos($path, self::AS3_DOMAIN) !== false) {
return $this->s3->deleteObject($this->s3->bucket, $this->s3->path . basename($path));
}
return $this->uploader->delete($path);
}
示例5: delete
public function delete()
{
if ($this->isHydrated()) {
$s3 = new S3(AMAZON_AWS_KEY, AMAZON_AWS_SECRET);
$s3->deleteObject($this->get('bucket'), $this->get('path'));
}
parent::delete();
}
示例6: deleteFile
function deleteFile($filename)
{
$s3svc = new S3();
// Removing the first slash is important - otherwise the URL is different.
$aws_filename = eregi_replace('^/', '', $filename);
$s3svc->deleteObject($aws_filename, MIRROR_S3_BUCKET);
unset($s3svc);
}
示例7: deleteSourceFolder
/**
* @inheritDoc BaseAssetSourceType::deleteSourceFolder()
*
* @param AssetFolderModel $parentFolder
* @param $folderName
*
* @return bool
*/
protected function deleteSourceFolder(AssetFolderModel $parentFolder, $folderName)
{
$this->_prepareForRequests();
$bucket = $this->getSettings()->bucket;
$objectsToDelete = $this->_s3->getBucket($bucket, $this->_getPathPrefix() . $parentFolder->path . $folderName);
foreach ($objectsToDelete as $uri) {
@$this->_s3->deleteObject($bucket, $uri['name']);
}
return true;
}
示例8: deleteDirectory
/**
* Delete directory
*
* @param string $path Short path
*
* @return boolean
*/
public function deleteDirectory($path)
{
$result = false;
try {
foreach ($this->readDirectory($path) as $k => $v) {
$this->client->deleteObject(\XLite\Core\Config::getInstance()->CDev->AmazonS3Images->bucket, $k);
}
$result = $this->delete($path);
} catch (\S3Exception $e) {
$result = false;
\XLite\Logger::getInstance()->registerException($e);
}
return $result;
}
示例9: delete
public function delete()
{
$appHouseAds = AppHouseAdUtil::getAppHouseAdsByCid($this->id);
foreach ($appHouseAds as $appHouseAd) {
$appHouseAd->delete();
}
if (!empty($this->imageLink)) {
if (extension_loaded('curl') && !@dl(PHP_SHLIB_SUFFIX == 'so' ? 'curl.so' : 'php_curl.dll')) {
$s3 = new S3(HouseAd::$HOUSEAD_AWS_KEY, HouseAd::$HOUSEAD_AWS_SECRET);
$s3->deleteObject(HouseAd::$HOUSEAD_BUCKET, basename($this->imageLink));
}
}
parent::delete();
CacheUtil::invalidateCustom($this->id);
}
示例10: 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;
}
示例11: lblDelete_Click
public function lblDelete_Click($strFormId, $strControlId, $strParameter)
{
$objAttachment = Attachment::Load($strParameter);
if (AWS_S3) {
require __DOCROOT__ . __PHP_ASSETS__ . '/s3.class.php';
$objS3 = new S3();
$objS3->deleteObject('attachments/' . $objAttachment->TmpFilename, AWS_BUCKET);
} else {
if (file_exists($objAttachment->Path)) {
unlink($objAttachment->Path);
}
}
$objAttachment->Delete();
if ($this->objParentControl) {
$this->objParentControl->pnlAttachments_Create();
} else {
$this->objForm->pnlAttachments_Create();
}
}
示例12: 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;
}
示例13: lblDelete_Click
public function lblDelete_Click($strFormId, $strControlId, $strParameter)
{
$objAttachment = Attachment::Load($strParameter);
if (AWS_S3) {
require __DOCROOT__ . __PHP_ASSETS__ . '/S3.php';
$objS3 = new S3(AWS_ACCESS_KEY, AWS_SECRET_KEY);
$strS3Path = AWS_PATH != '' ? ltrim(AWS_PATH, '/') . '/' : '';
$objS3->deleteObject(AWS_BUCKET, $strS3Path . 'attachments/' . $objAttachment->TmpFilename);
} else {
if (file_exists($objAttachment->Path)) {
unlink($objAttachment->Path);
}
}
$objAttachment->Delete();
if ($this->objParentControl) {
$this->objParentControl->pnlAttachments_Create();
} else {
$this->objForm->pnlAttachments_Create();
}
}
示例14: beforeDelete
/**
* Method called automatically by model's delete
*
* @param object $model Object of model
* @return boolean Return's true if delete should continue, false otherwise
*/
function beforeDelete(&$model)
{
App::import('Vendor', 'S3', array('file' => 'S3.php'));
foreach ($this->settings[$model->name] as $field => $options) {
$accessKey = $this->__accessKey;
$secretKey = $this->__secretKey;
// If we have S3 credentials for this field/file
if (!empty($options['s3_access_key']) && !empty($options['s3_secret_key'])) {
$accessKey = $options['s3_access_key'];
$secretKey = $options['s3_secret_key'];
}
// Instantiate the class
$aws = new S3($accessKey, $secretKey);
// Get model's data for filename of photo
$filename = $model->field($model->name . '.' . $field);
// If filename is found then delete original photo
if (!empty($filename)) {
$aws->deleteObject($options['s3_bucket'], $filename);
}
}
// Return true by default
return true;
}
示例15: rename_icon
/**
* rename location icon
* @param string $new_name
* @return boolean
*/
public function rename_icon($new_name)
{
if (!$this->_loaded) {
throw new Kohana_Exception('Cannot delete :model model because it is not loaded.', array(':model' => $this->_object_name));
}
@rename('images/locations/' . $this->seoname . '.png', 'images/locations/' . $new_name . '.png');
if (core::config('image.aws_s3_active')) {
require_once Kohana::find_file('vendor', 'amazon-s3-php-class/S3', 'php');
$s3 = new S3(core::config('image.aws_access_key'), core::config('image.aws_secret_key'));
$s3->copyObject(core::config('image.aws_s3_bucket'), 'images/locations/' . $this->seoname . '.png', core::config('image.aws_s3_bucket'), 'images/locations/' . $new_name . '.png', S3::ACL_PUBLIC_READ);
$s3->deleteObject(core::config('image.aws_s3_bucket'), 'images/locations/' . $this->seoname . '.png');
}
}