]> BookStack Code Mirror - bookstack/blobdiff - app/Uploads/AttachmentService.php
TS: Converted dom and keyboard nav services
[bookstack] / app / Uploads / AttachmentService.php
index ddabec09f2733663486fdc301d4b8dbb35ceed11..bd319fbd795af717c4c026d63b9b8bc58ea7fabd 100644 (file)
@@ -4,7 +4,6 @@ namespace BookStack\Uploads;
 
 use BookStack\Exceptions\FileUploadException;
 use Exception;
-use Illuminate\Contracts\Filesystem\FileNotFoundException;
 use Illuminate\Contracts\Filesystem\Filesystem as Storage;
 use Illuminate\Filesystem\FilesystemManager;
 use Illuminate\Support\Facades\Log;
@@ -66,8 +65,6 @@ class AttachmentService
     /**
      * Stream an attachment from storage.
      *
-     * @throws FileNotFoundException
-     *
      * @return resource|null
      */
     public function streamAttachmentFromStorage(Attachment $attachment)
@@ -75,6 +72,14 @@ class AttachmentService
         return $this->getStorageDisk()->readStream($this->adjustPathForStorageDisk($attachment->path));
     }
 
+    /**
+     * Read the file size of an attachment from storage, in bytes.
+     */
+    public function getAttachmentFileSize(Attachment $attachment): int
+    {
+        return $this->getStorageDisk()->size($this->adjustPathForStorageDisk($attachment->path));
+    }
+
     /**
      * Store a new attachment upon user upload.
      *