本文整理汇总了PHP中Aws\S3\S3Client::deleteObject方法的典型用法代码示例。如果您正苦于以下问题:PHP S3Client::deleteObject方法的具体用法?PHP S3Client::deleteObject怎么用?PHP S3Client::deleteObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Aws\S3\S3Client
的用法示例。
在下文中一共展示了S3Client::deleteObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete
/**
* {@inheritdoc}
*/
public function delete($path)
{
try {
$this->s3->deleteObject(['Bucket' => $this->bucket, 'Key' => $path]);
} catch (AwsExceptionInterface $e) {
throw Exception\StorageException::deleteError($path, $e);
}
}
示例2: remove
/**
* @param $filename
* @return \Aws\Result|null
*/
public function remove($filename)
{
$result = null;
try {
$result = $this->s3->deleteObject(['Bucket' => $this->bucket, 'Key' => $filename]);
} catch (\Exception $e) {
}
return $result;
}
示例3: delete
/**
* @param $path
*
* @return bool
* @throws FileException
*/
public function delete($path)
{
try {
$this->s3->deleteObject(['Bucket' => $this->bucket, 'Key' => $path]);
} catch (\Exception $e) {
throw new FileException('File was not removed from filesystem', $e->getCode(), $e);
}
return true;
}
示例4: delete
/**
* Delete remote file
*
* @param string $path Remote Path
*
* @return bool
* @throws
*/
public function delete($path)
{
$path = trim($path, '/');
if (!$this->isFile($path)) {
$path = $this->bucket . "/" . $path;
throw new ExceptionStorage("File {$path} Not found or Not Is File", static::E_NOT_IS_FILE);
}
$response = $this->clientS3->deleteObject(array('Bucket' => $this->bucket, 'Key' => $path));
return (bool) $response;
}
示例5: remove
/**
* {@inheritDoc}
*/
public function remove(array $paths, array $filters)
{
if (empty($paths) && empty($filters)) {
return;
}
if (empty($paths)) {
try {
$this->storage->deleteMatchingObjects($this->bucket, null, sprintf('/%s/i', implode('|', $filters)));
} catch (\Exception $e) {
$this->logError('The objects could not be deleted from Amazon S3.', array('filter' => implode(', ', $filters), 'bucket' => $this->bucket, 'exception' => $e));
}
return;
}
foreach ($filters as $filter) {
foreach ($paths as $path) {
$objectPath = $this->getObjectPath($path, $filter);
if (!$this->objectExists($objectPath)) {
continue;
}
try {
$this->storage->deleteObject(array('Bucket' => $this->bucket, 'Key' => $objectPath));
} catch (\Exception $e) {
$this->logError('The object could not be deleted from Amazon S3.', array('objectPath' => $objectPath, 'filter' => $filter, 'bucket' => $this->bucket, 'exception' => $e));
}
}
}
}
示例6: rename
/**
* rename file/directory
*
* @return string
*/
public function rename()
{
$oldPath = $this->sanitizePath($this->get['old']);
$isDir = $this->isDir($this->metadata("{$oldPath}"));
$oldPath .= $isDir ? '/' : '';
$contents = $isDir ? $this->s3->listObjects(['Bucket' => $this->bucket, 'Prefix' => $oldPath])['Contents'] : array();
// NOTE: we do this instead of isDir as we only care if there are files under this prefix
if (count($contents) > 1) {
$this->error('Unfortunately, we are currently unable to rename a non-empty directory.', false);
}
$pathInfo = pathinfo($oldPath);
$dirName = $pathInfo['dirname'];
$baseName = $pathInfo['basename'];
$newFile = $this->get['new'];
$newPath = join('/', array($dirName, $newFile));
if ($isDir) {
$response = $this->createDirectory($newPath);
} else {
$response = $this->s3->copyObject(['Bucket' => $this->bucket, 'CopySource' => urlencode($this->bucket . '/' . $oldPath), 'Key' => $newPath]);
// array('bucket' => $this->bucket, 'filename' => $oldPath),
// array('bucket' => $this->bucket, 'filename' => $newPath),
// array('acl' => CannedAcl::PUBLIC_READ)
// );
}
if (!empty($response)) {
$this->s3->deleteObject(['Bucket' => $this->bucket, 'Key' => $oldPath]);
//$this->bucket, $oldPath);
}
return array('Error' => '', 'Code' => 0, 'Old Path' => $oldPath, 'Old Name' => $baseName, 'New Path' => $newPath, 'New Name' => $newFile);
}
示例7: _unlink
/**
* Remove file
*
* @param string $path file path
* @return Guzzle\Service\Resource\Model
**/
protected function _unlink($path)
{
$clear = new \Aws\S3\Model\ClearBucket($this->s3, $this->bucket);
$iterator = $this->s3->getIterator('ListObjects', array('Bucket' => $this->bucket, 'Prefix' => $this->pathToKey($path)));
$clear->setIterator($iterator);
$clear->clear();
return $this->s3->deleteObject(array("Bucket" => $this->bucket, "Key" => $this->pathToKey($path)));
}
示例8: deleteFile
/**
* Deletes an object given its key
* @param $key Key name on S3 bucket
* @return bool
*/
public function deleteFile($key)
{
$res = $this->s3Client->deleteObject(array('Bucket' => $this->bucketName, 'Key' => $key));
if ($res) {
return true;
} else {
return false;
}
}
示例9: unpublishResource
/**
* Unpublishes the given persistent resource
*
* @param \TYPO3\Flow\Resource\Resource $resource The resource to unpublish
* @return void
*/
public function unpublishResource(Resource $resource)
{
try {
$objectName = $this->keyPrefix . $this->getRelativePublicationPathAndFilename($resource);
$this->s3Client->deleteObject(array('Bucket' => $this->bucketName, 'Key' => $objectName));
$this->systemLogger->log(sprintf('Successfully unpublished resource as object "%s" (MD5: %s) from bucket "%s"', $objectName, $resource->getMd5() ?: 'unknown', $this->bucketName), LOG_DEBUG);
} catch (\Exception $e) {
}
}
示例10: deleteBlob
/**
* @param string $container
* @param string $name
*
* @throws DfException
*/
public function deleteBlob($container = '', $name = '')
{
try {
$this->checkConnection();
$this->blobConn->deleteObject(['Bucket' => $container, 'Key' => $name]);
} catch (\Exception $ex) {
throw new DfException('Failed to delete blob "' . $name . '": ' . $ex->getMessage());
}
}
示例11: _rmdir
/**
* Remove dir
*
* @param string $path dir path
* @return bool
* @author Dmitry (dio) Levashov
**/
protected function _rmdir($path)
{
$newkey = $this->_normpath($path) . '/';
try {
$obj = $this->s3->deleteObject(array('Bucket' => $this->options['bucket'], 'Key' => $newkey));
return true;
} catch (Exception $e) {
}
return false;
}
示例12: delete
/**
* Deletes one or more files from DFS
*
* @param string|array $filePath
* Single local filename, or array of local filenames
*
* @return bool true if deletion was successful, false otherwise
*/
public function delete($filePath)
{
try {
$this->s3client->deleteObject(array('Bucket' => $this->bucket, 'Key' => $filePath));
return true;
} catch (S3Exception $e) {
eZDebug::writeError($e->getMessage(), __METHOD__);
return false;
}
}
示例13: _unlink
/**
* Remove file
*
* @param string $path file path
* @return bool
* @author Dmitry (dio) Levashov
**/
protected function _unlink($path)
{
$newkey = $this->_normpath($path);
$newkey = preg_replace("/\\/\$/", "", $newkey);
try {
$obj = $this->s3->deleteObject(array('Bucket' => $this->options['bucket'], 'Key' => $newkey));
return true;
} catch (Exception $e) {
}
return false;
}
示例14: deleteObject
/**
* @param $awsPath aws file to delete
* @return mixed|null
* @throws Exception
*/
private function deleteObject($bucket, $awsPath)
{
$this->logger->debug('delete ' . $awsPath . ' from ' . $bucket . ' bucket ...');
$result = $this->s3->deleteObject(array('Bucket' => $bucket, 'Key' => $awsPath));
try {
return $result;
$this->logger->debug('delete ' . $awsPath . ' from ' . $bucket . ' bucket ! done');
} catch (AwsException $e) {
throw $e;
}
}
示例15: unlink
public function unlink($path)
{
$path = $this->normalizePath($path);
try {
$result = $this->connection->deleteObject(array('Bucket' => $this->bucket, 'Key' => $path));
$this->testTimeout();
} catch (S3Exception $e) {
\OCP\Util::writeLog('files_external', $e->getMessage(), \OCP\Util::ERROR);
return false;
}
return true;
}