Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filesystem with Digital Ocean spaces or S3 #2173

Closed
rapsli opened this issue Aug 22, 2022 · 7 comments
Closed

Filesystem with Digital Ocean spaces or S3 #2173

rapsli opened this issue Aug 22, 2022 · 7 comments
Labels
help wanted Extra attention is needed

Comments

@rapsli
Copy link

rapsli commented Aug 22, 2022

Unfortunately the documentation here is not very clear. First of all it will not work with PHP > 8 So I have downgraded to PHP 7.4.

Installing the required package:

composer require league/flysystem-aws-s3-v3 ~1.0

I haved added the S3 and DO credentials to the .envfile for either S3 or DO spaces. It was never running. It was sometimes uploading vars.js to either S3 or DO, but that was about it. I could never get it to upload the actual attachments.

What is not quite clear:

  • Are there any changes required in conf/filesystems.php? I have added a DO disk similar to the s3 disk, to test out the DO configuration, but unfortunately with no success. When changing the FILESYSTEM_DRIVER from local to s3 I get the following error:
During inheritance of Countable: Uncaught ErrorException: Return type of Aws\HandlerList::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
in /home/runcloud/webapps/freescout/vendor/aws/aws-sdk-php/src/HandlerList.php:308

Do I have to remove any files from storage in order for S3 to work?

@freescout-helpdesk
Copy link
Contributor

It looks like the package you are using is not compatible with PHP 8.1

@rapsli
Copy link
Author

rapsli commented Aug 22, 2022

yes I agree, that's why I have downgraded to PHP 7.4... but even so it's not working

@rapsli
Copy link
Author

rapsli commented Aug 22, 2022

A quick update. I can now upload files again: the URL points to the file on AWS, but the file is actually uploaded to the local storage (/storage/app/attachment) and nothing arrives at AWS. Clicking on the file will lead to a broken link.

image

@freescout-helpdesk freescout-helpdesk changed the title filesystem with Digital Ocean spaces or S3 not working Filesystem with Digital Ocean spaces or S3 Sep 2, 2022
@freescout-helpdesk
Copy link
Contributor

We've never tried this ourselves. We'll leave this issue as help wanted. Maybe someone will help.

@freescout-helpdesk freescout-helpdesk added the help wanted Extra attention is needed label Sep 2, 2022
@rapsli
Copy link
Author

rapsli commented Jan 16, 2023

any news here? Just tried to setup another instance... not having to worry about storage for attachments would make life a lot easier!

@rapsli
Copy link
Author

rapsli commented Jan 17, 2023

Got it running. Here is what I had to change. This is now obviously hardcoded I would assume, it will need some more love, but I'm not familiar at all with Laravel, so hopefully someone smarter than me with a more oversights can get this into a generic form.


diff --git a/app/Attachment.php b/app/Attachment.php
index 2fc5d687..5a555341 100644
--- a/app/Attachment.php
+++ b/app/Attachment.php
@@ -19,7 +19,7 @@ class Attachment extends Model

     const DIRECTORY = 'attachment';

-    CONST DISK = 'private';
+    CONST DISK = 's3';

     // https://github.com/Webklex/laravel-imap/blob/master/src/IMAP/Attachment.php
     public static $types = [
@@ -231,7 +231,9 @@ class Attachment extends Model
      */
     public function url()
     {
-        return Storage::url($this->getStorageFilePath()).'?id='.$this->id.'&token='.$this->getToken();
+
+       return Storage::disk('s3')->temporaryUrl($this->getStorageFilePath(), now()->addMinutes(30));
+        //return Storage::url($this->getStorageFilePath()).'?id='.$this->id.'&token='.$this->getToken();
     }

@freescout-helpdesk
Copy link
Contributor

Thanks for sharing the solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants