From 1091825b2068694d1ec847a4c1784fd1939587ee Mon Sep 17 00:00:00 2001 From: overtrue Date: Sun, 2 Apr 2017 13:52:45 +0800 Subject: [PATCH] :sparkles: Add getUrl method. --- README.md | 2 ++ src/QiniuAdapter.php | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5e2f469..e9b0500 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,8 @@ array $flysystem->getMetadata('file.md'); int $flysystem->getSize('file.md'); +string $flysystem->getUrl('file.md'); + string $flysystem->getMimetype('file.md'); int $flysystem->getTimestamp('file.md'); diff --git a/src/QiniuAdapter.php b/src/QiniuAdapter.php index 2eec8ce..cd7aa94 100644 --- a/src/QiniuAdapter.php +++ b/src/QiniuAdapter.php @@ -210,6 +210,18 @@ public function has($path) return !$error || is_array($response); } + /** + * Get resource url. + * + * @param string $path + * + * @return string + */ + public function getUrl($path) + { + return $this->normalizeHost($this->domain).$path; + } + /** * Read a file. * @@ -219,7 +231,7 @@ public function has($path) */ public function read($path) { - $contents = file_get_contents($this->normalizeHost($this->domain).$path); + $contents = file_get_contents($this->getUrl($path)); return compact('contents', 'path'); }