當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。