Closed afdev82 closed 3 years ago
Maybe a possible solution would be to identify the datastore in use and only if the datastore is s3 replace the classes in this block:
https://github.com/AlchemyCMS/alchemy-dragonfly-s3/blob/main/lib/alchemy/dragonfly/s3/engine.rb#L9
This gem is meant to be used with a s3 setup. If you want to use it only in production, then the gem needs to be in the production gem group and you need to adjust your app to reflect that. There are many advantages in using this gem and s3 in development as well, but this is totally up to you and not the responsibility of this gem.
Regarding the missing methods (url
and remote_url
): These methods are defined by the datastore and are not available without it. You can either this datastore in development as well or use respond_to?
or is_a?
to check if they are available.
OK, got it. Thank you.
At first I included this gem for all environment in my Gemfile in order to use the S3 storage on Heroku. Before I was using the file data store for all my environment, but since Heroku doesn't support it, I had to use S3 in production. I'm using AlchemyCMS v4.6.2 and for that reason I used the branch 'alchemy-4'. Dragonfly v1.3.0 and Rails v6.0.3.6. If I use only the s3 data store in the dragonfly configuration, everything is fine. But in this way I'm forced to use s3 also in development, I wanted to use my local filesystem instead (like before the change). So I reverted the dragonfly configuration like it was before, eg:
After this change I get the following error if I try to load a page:
If I move this gem only in the group for the production / staging environments, the error is gone. I think this is a bug, because it should be possible to do something like that in the dragonfly configuration to use different datastores based on the environment:
Then I face another problem if I try to get the url for a video essence, not strictly related with this issue, but I'm wondering if there is a unified way to get the url of the resource in all environment, considering the different configuration of dragonfly. Using the s3 datastore I had to change the way to get the url for the video in the view from
to
Because Safari won't play the video when the byte range requests are not supported (eg. on Heroku web server). Now in development I have to use the first code and in production the second one, otherwise I get:
I saw that the
url
method is defined in this gem here. It would be very ugly to have a conditional statement based on the environment to choose at runtime what to use in the view, but at the moment is the only solution that I can see. Something like that:From my point of view, there is no way to use my local filesystem in development and s3 in production, only one datastore for both. But it sounds very strange to me, are there possible solutions to this problem?