Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Processing file before upload using ActiveStorage

How would I process a file before it's uploaded using activestorage. I need to be able to modify an svg file's content before it actually gets uploaded to S3. Can't seem to find any callbacks.

like image 666
Ilya Sterin Avatar asked May 13 '26 12:05

Ilya Sterin


1 Answers

There is no way to do this natively with ActiveStorage. It's the major drawback with using ActiveStorage.

As far as I know, the only way to modify an upload is to create a variant of the original upload after it is created...which creates a (completely different) variant image based on the image that was originally uploaded.

ActiveStorage is easy to setup but, after using it with a few applications, Carrierwave..etc seem like better options.

In addition, if you want to upload in a background job, ActiveStorage is a pain.

like image 188
Mark Merritt Avatar answered May 15 '26 05:05

Mark Merritt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!