1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-08-09 10:22:51 +03:00

Allowed different storage types for images and attachments

- Added new env and config vars to allow this.
- Also added tests for awkward config logic including fallback for new
env vars.

Closes #1302
This commit is contained in:
Dan Brown
2019-06-23 16:01:15 +01:00
parent bf1371d04c
commit 762d1d7595
7 changed files with 79 additions and 7 deletions

View File

@@ -13,7 +13,7 @@ class AttachmentService extends UploadService
*/
protected function getStorage()
{
$storageType = config('filesystems.default');
$storageType = config('filesystems.attachments');
// Override default location if set to local public to ensure not visible.
if ($storageType === 'local') {

View File

@@ -45,9 +45,9 @@ class ImageService extends UploadService
*/
protected function getStorage($type = '')
{
$storageType = config('filesystems.default');
$storageType = config('filesystems.images');
// Override default location if set to local public to ensure not visible.
// Ensure system images (App logo) are uploaded to a public space
if ($type === 'system' && $storageType === 'local_secure') {
$storageType = 'local';
}
@@ -458,7 +458,7 @@ class ImageService extends UploadService
// Get the standard public s3 url if s3 is set as storage type
// Uses the nice, short URL if bucket name has no periods in otherwise the longer
// region-based url will be used to prevent http issues.
if ($storageUrl == false && config('filesystems.default') === 's3') {
if ($storageUrl == false && config('filesystems.images') === 's3') {
$storageDetails = config('filesystems.disks.s3');
if (strpos($storageDetails['bucket'], '.') === false) {
$storageUrl = 'https://' . $storageDetails['bucket'] . '.s3.amazonaws.com';