本文整理汇总了PHP中Aws\S3\S3Client::doesObjectExist方法的典型用法代码示例。如果您正苦于以下问题:PHP S3Client::doesObjectExist方法的具体用法?PHP S3Client::doesObjectExist怎么用?PHP S3Client::doesObjectExist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Aws\S3\S3Client
的用法示例。
在下文中一共展示了S3Client::doesObjectExist方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: importTemporaryFile
/**
* Imports the given temporary file into the storage and creates the new resource object.
*
* @param string $temporaryPathAndFilename Path and filename leading to the temporary file
* @param string $collectionName Name of the collection to import into
* @return Resource The imported resource
*/
protected function importTemporaryFile($temporaryPathAndFilename, $collectionName)
{
$sha1Hash = sha1_file($temporaryPathAndFilename);
$md5Hash = md5_file($temporaryPathAndFilename);
$resource = new Resource();
$resource->setFileSize(filesize($temporaryPathAndFilename));
$resource->setCollectionName($collectionName);
$resource->setSha1($sha1Hash);
$resource->setMd5($md5Hash);
$objectName = $this->keyPrefix . $sha1Hash;
$options = array('Bucket' => $this->bucketName, 'Body' => fopen($temporaryPathAndFilename, 'rb'), 'ContentLength' => $resource->getFileSize(), 'ContentType' => $resource->getMediaType(), 'Key' => $objectName);
if (!$this->s3Client->doesObjectExist($this->bucketName, $this->keyPrefix . $sha1Hash)) {
$this->s3Client->putObject($options);
$this->systemLogger->log(sprintf('Successfully imported resource as object "%s" into bucket "%s" with MD5 hash "%s"', $objectName, $this->bucketName, $resource->getMd5() ?: 'unknown'), LOG_INFO);
} else {
$this->systemLogger->log(sprintf('Did not import resource as object "%s" into bucket "%s" because that object already existed.', $objectName, $this->bucketName), LOG_INFO);
}
return $resource;
}
示例2: has
/**
* Check whether a file exists.
*
* @param string $path
*
* @return bool
*/
public function has($path)
{
$location = $this->applyPathPrefix($path);
if ($this->s3Client->doesObjectExist($this->bucket, $location)) {
return true;
}
return $this->doesDirectoryExist($location);
}
示例3: blobExists
/**
* Check if a blob exists
*
* @param string $container Container name
* @param string $name Blob name
*
* @return boolean
*/
public function blobExists($container = '', $name = '')
{
try {
$this->checkConnection();
return $this->blobConn->doesObjectExist($container, $name);
} catch (\Exception $ex) {
return false;
}
}
示例4: existsOnDFS
/**
* Checks if a file exists on the DFS
*
* @param string $filePath
*
* @return bool
*/
public function existsOnDFS($filePath)
{
try {
return $this->s3client->doesObjectExist($this->bucket, $filePath);
} catch (S3Exception $e) {
eZDebug::writeError($e->getMessage(), __METHOD__);
return false;
}
}
示例5: exists
/**
* Return whether a file exists.
*
* @param string $file
* @return boolean Whether the file exists
* @throws \RuntimeException
*/
public function exists($file)
{
if (null !== $this->filenameFilter) {
$file = $this->filenameFilter->filter($file);
}
try {
return $this->s3Client->doesObjectExist($this->getBucket(), $file);
} catch (S3Exception $e) {
if (!$this->getThrowExceptions()) {
return false;
}
throw new \RuntimeException('Exception thrown by Aws\\S3\\S3Client: ' . $e->getMessage(), null, $e);
}
}
示例6: filetype
public function filetype($path)
{
$path = $this->normalizePath($path);
try {
if ($path != '.' && $this->connection->doesObjectExist($this->bucket, $path)) {
return 'file';
}
if ($path != '.') {
$path .= '/';
}
if ($this->connection->doesObjectExist($this->bucket, $this->cleanKey($path))) {
return 'dir';
}
} catch (S3Exception $e) {
\OCP\Util::writeLog('files_external', $e->getMessage(), \OCP\Util::ERROR);
return false;
}
return false;
}
示例7: saveImage
protected function saveImage(array $file, $subdirectory = '')
{
$s3 = new S3Client(['version' => 'latest', 'region' => 'eu-west-1']);
$subdirectory = trim($subdirectory, '/');
list($name, $extension) = explode('.', trim($file['name'], '/'));
$filename = md5((string) rand()) . '.' . $extension;
$directory = self::$public_image_directory . '/' . $subdirectory . '/';
$bucket_name = 'comp3013';
if (!$s3->doesBucketExist($bucket_name)) {
echo 'Error, bucket didnt exist';
exit(0);
}
while ($s3->doesObjectExist($bucket_name, $directory . $filename)) {
$filename = md5((string) rand()) . '.' . $extension;
}
$parameters = ['ContentType' => $file['type'], 'Bucket' => $bucket_name, 'Key' => $directory . $filename, 'SourceFile' => $file['tmp_name']];
print_r($parameters);
$s3->putObject($parameters);
$s3->waitUntil('ObjectExists', ['Bucket' => $bucket_name, 'Key' => $directory . $filename]);
//exit(0);
return 'http://comp3013.s3-website-eu-west-1.amazonaws.com/' . $directory . $filename;
}
示例8: isDir
/**
* If path is diretory
*
* @param string $path Remote folder
*
* @return bool
*/
public function isDir($path)
{
$path = trim($path, '/') . '/';
return $this->clientS3->doesObjectExist($this->bucket, $path);
}
示例9: objectExists
/**
* Checks whether an object exists.
*
* @param string $objectPath
*
* @return bool
*/
protected function objectExists($objectPath)
{
return $this->storage->doesObjectExist($this->bucket, $objectPath);
}
示例10: exists
public function exists($key)
{
$this->load();
return $this->s3Client->doesObjectExist(S3Cache::BUCKET, $key);
}
示例11: _removeFileFromS3
/**
* _removeFileFromS3
*
* @param string $file Path of the file
* @param \Cake\ORM\Entity $entity Entity to check on.
* @param string $field Field to check on.
* @return bool
*/
protected function _removeFileFromS3($file, $entity, $field)
{
if ($file != null && $file != '') {
// Only if a file exist!
$bucketName = $this->_getBucketName($this->_customerSite, $field);
if ($this->_s3Client->doesObjectExist($bucketName, $file)) {
$result = $this->_s3Client->deleteObject(array('Bucket' => $bucketName, 'Key' => $file));
}
}
//TODO: migliorare il ritorno
return true;
}
示例12: doesObjectExist
/**
* Determines whether or not an object exists by name
*
* @param string $bucket The name of the bucket
* @param string $key The key of the object
* @param array $params Additional options to add to the executed command
*
* @return bool
*/
public function doesObjectExist($bucket, $key, array $params = [])
{
return $this->instance->doesObjectExist($bucket, $key, $params);
}
示例13: doesObjectExist
/**
* 指定パスのファイルがS3にあるかどうかを判別する
*
* @param string $path
* @return boolean
**/
public function doesObjectExist($path)
{
return $this->client->doesObjectExist($this->bucket, $path);
}
示例14: exists
/**
* Check existing current file in current file system
* @param $url string Url
* @return boolean File exists or not
*/
public function exists($url)
{
// Get file key name on amazon s3
$fileKey = str_replace($this->bucketURL, '', $url);
return $this->client->doesObjectExist($this->bucket, $fileKey);
}
示例15: has
/**
* Asks the driver if it has a particular file.
*
* @param FileModel $fileModel
* @param array $options
* @return bool
*/
public function has(FileModel $fileModel, array $options = [])
{
// Check if file exists
return $this->s3->doesObjectExist($this->awsBucket, $this->nameGenerator->fileName($fileModel, $options));
}