Skip to content

Commit

Permalink
Merge pull request #74 from nao-pon/patch-6
Browse files Browse the repository at this point in the history
support "Onetime URL" or "Temporary URL"
  • Loading branch information
barryvdh authored Jan 15, 2019
2 parents ed6d227 + 19c8cde commit c4b6c4b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -799,12 +799,23 @@ public function getImageSize($path, $mime = '')
**/
public function getContentUrl($hash, $options = array())
{
if (! empty($options['onetime']) && $this->options['onetimeUrl']) {
// use parent method to make onetime URL
return parent::getContentUrl($hash, $options);
}
if (!empty($options['temporary'])) {
// try make temporary file
$url = parent::getContentUrl($hash, $options);
if ($url) {
return $url;
}
}
if (($file = $this->file($hash)) == false || !isset($file['url']) || !$file['url'] || $file['url'] == 1) {
if ($file && !empty($file['url']) && !empty($options['temporary'])) {
return parent::getContentUrl($hash, $options);
}
$path = $this->decode($hash);
if ($res = $this->fs->getUrl($path) || empty($options['temporary'])) {
if (($res = $this->fs->getUrl($path)) || empty($options['temporary'])) {
return $res;
} else {
return parent::getContentUrl($hash, $options);
Expand Down

0 comments on commit c4b6c4b

Please sign in to comment.