-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uploading to S3 while model is being created #66
Comments
Your question is a bit too generic because you didn't specified if you are trying to store files in dedicated folders and/or you're going to generate several versions of the image. As a hint, you can do this:
if you also want different versions, then modify the function like this:
hope this helps ;-) |
Here's the final solution that satisfied me - works without adding additional field to schema, and instead renames uploaded filename and persists that to database: Person model:
Photo uploader:
Works really well: all versions are saved, useless original filename is not persisted, instead it renames it to UUID and deals with that normally. |
Does it work across non-valid forms? It looks like your UUID generation happens every time you call That's why I've used an additional field on schema. For completeness, here's how I've implemented
as you can see, I don't care about filenames, but I care to store file(s) under a unique folder. |
Believe this is duplicate of #15 |
@andreyk-code they're related because that's the same problem, but they don't solve it as well. btw, I've forked arc_ecto to use a different approach/workaround. it's not perfect, but it's working well in production on 2 apps. Here's the fork in case you're interested: https://github.com/FunkyStudioHQ/arc_ecto_ng |
Apologies for using issues as a request for help, but hopefully someone can help me.
In the form, User model is created and avatar is uploaded at the same time. It means that Avatar is uploaded before User is created and has an id. I would like to give a photo UUID (rename from original filename my_photo.jpg to UUID.jpg) and persist that, instead of original file_name, like arc_ecto does by default.
What should I do to rename uploaded file to UUID and persist that to a database (instead of original filename)?
The text was updated successfully, but these errors were encountered: