public function getBaseUrl($file)
 {
     switch (Storage::getDefaultDriver()) {
         case 'local':
             return Storage::getDriver()->getAdapter()->getPathPrefix() . '/' . $file->id . '.' . $file->extension;
     }
 }
Example #2
0
 /**
  * Get the URI path of the file.
  *
  * @param string $filename
  *
  * @return null|string
  */
 protected function getUploadUri($filename)
 {
     // Setup the default variable value.
     $path = null;
     // If the file exists, get the URI for it.
     if ($this->filesystem->exists($filename)) {
         // If filesystem disk is Local, get the public_path of the file located locally.
         if ($this->disk == 'local') {
             $url = config('app.url') . '/uploads';
             $path = "{$url}/{$filename}";
         }
         // If filesystem disk is Amazon S3, get the actual URI for the file located in the Amazon S3 bucket.
         if ($this->disk == 's3') {
             $path = $this->filesystem->getDriver()->getAdapter()->getClient()->getObjectUrl(config('filesystems.disks.s3.bucket'), $filename);
         }
     }
     return $path;
 }