3 months ago

How do I move my images to s3 in production and in development let it stay locally?

Posted 3 months ago by shadrix

I have read this thread, however I'm still not really sure how to handle this.

Of course, I could set FILESYSTEM_DRIVER to s3, but this won't really work.

Let me explain:

If we upload a simple avatar file:

        ->store('avatars', 'public')

The file is saved in the DB for example: avatars/R6ZGC9U0c22mKMcAADZbc8kJeU8soTvOuNFvnYgv.jpeg

This file is stored in the local public storage file. However, if we now want to change the default filesystem to S3, nothing is going to change obviously.

Now, this is going to be even harder, when we fetch the image via the assetmethod. Usually, I just need to write:

 public function getAvatarAttribute($avatar)
    return asset('storage/' . $avatar));

to get the avatar file (because of the symlink in the public folder).

What now? I obviously don't save a storage folder.

How would you handle this?

Please sign in or create an account to participate in this conversation.