Ash FrameworkAF
Ash Framework5mo ago
9 replies
pistrie

Good way to (atomically?) persist a file when creating a record?

I'm working on a little project where one of the features is the ability to upload a file (using the :upload action which currently takes a :name and a :path as its arguments), which persists the file to disk and creates a File record in the DB. I want to do this in such a way that that I never end up with files on the disk that the DB doesn't know about, but also that no record is created if the file persistence has failed.

How would I achieve this?
Was this page helpful?