stavro / arc_ecto

An integration with Arc and Ecto.
255 stars 149 forks source link

Overridden filename not stored in the database #84

Closed AppyCat closed 6 years ago

AppyCat commented 6 years ago

The below works to rename the file, but it does not rename what is stored in the database as the name of the file.

def filename(version, _) do "#{UUID.uuid1()}" end

The file name in the database remains the original file name, instead of the overridden version from the uuid above.

If the filename and what is stored in the db differ, the system is broken. Carrierwave updates the db with the new overridden file name. Is it possible to do the same with arc_ecto?

pedep commented 6 years ago

see https://github.com/stavro/arc/issues/85 and related issues for more

pedep commented 6 years ago

Duplicate of https://github.com/stavro/arc/issues/85

williamweckl commented 6 years ago

@pedep I don't think this issue is the same as #85, it is the same problem reported at issue #69 but you closed both...

I'm having the same problem that @AppyCat reported. When I use the functions to retrieve the right filename is returned but at the database it saves the original filename from upload. The problem of doing that is if I change my filename or thumbnails strategy I lose compatibility with the old ones... Maybe use a JSON field to store all version names?

pedep commented 6 years ago

@williamweckl These issues may not be exactly the same, but they are similar enough that i believe solving one would mean solving all of them.

I'm not sure storing JSON in the database is the correct approach, since that would pose problems with databases that does not support embedded schema.

Do you think you could elaborate on what behavior you expect when changing the filename method? I'm pretty sure, that if you change your naming strategy in something like carrierwave, you would also have problems?