当前位置: 首页>>代码示例>>PHP>>正文


PHP S3Client::doesObjectExist方法代码示例

本文整理汇总了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;
 }
开发者ID:mkuiphuis,项目名称:flow-aws-s3,代码行数:26,代码来源:S3Storage.php

示例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);
 }
开发者ID:twistor,项目名称:flysystem-aws-s3-v3,代码行数:15,代码来源:AwsS3Adapter.php

示例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;
     }
 }
开发者ID:pkdevboxy,项目名称:df-aws,代码行数:17,代码来源:S3FileSystem.php

示例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;
     }
 }
开发者ID:ezsystems,项目名称:ezdfs-fsbackend-aws-s3,代码行数:16,代码来源:amazon.php

示例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);
     }
 }
开发者ID:dotsunited,项目名称:cabinet,代码行数:21,代码来源:AmazonS3Adapter.php

示例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;
 }
开发者ID:Combustible,项目名称:core,代码行数:19,代码来源:amazons3.php

示例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;
 }
开发者ID:sampayne,项目名称:COMP3013,代码行数:22,代码来源:Creator.php

示例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);
 }
开发者ID:naturalweb,项目名称:filestorage,代码行数:12,代码来源:S3Storage.php

示例9: objectExists

 /**
  * Checks whether an object exists.
  *
  * @param string $objectPath
  *
  * @return bool
  */
 protected function objectExists($objectPath)
 {
     return $this->storage->doesObjectExist($this->bucket, $objectPath);
 }
开发者ID:networksoft,项目名称:seekerplus.com,代码行数:11,代码来源:AwsS3Resolver.php

示例10: exists

 public function exists($key)
 {
     $this->load();
     return $this->s3Client->doesObjectExist(S3Cache::BUCKET, $key);
 }
开发者ID:silktide,项目名称:stash,代码行数:5,代码来源:Version2Layer.php

示例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;
 }
开发者ID:EnterpriseConsultingDeveloper,项目名称:cakephp-utils,代码行数:20,代码来源:UploadableBehavior.php

示例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);
 }
开发者ID:Webiny,项目名称:Framework,代码行数:13,代码来源:S3.php

示例13: doesObjectExist

 /**
  * 指定パスのファイルがS3にあるかどうかを判別する
  *
  * @param  string $path
  * @return boolean
  **/
 public function doesObjectExist($path)
 {
     return $this->client->doesObjectExist($this->bucket, $path);
 }
开发者ID:kknet,项目名称:AdultMidnight,代码行数:10,代码来源:S3.php

示例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);
 }
开发者ID:samsonphp,项目名称:fs_aws,代码行数:11,代码来源:AWSFileService.php

示例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));
 }
开发者ID:bmartel,项目名称:phperclip,代码行数:12,代码来源:S3.php


注:本文中的Aws\S3\S3Client::doesObjectExist方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。