-
Notifications
You must be signed in to change notification settings - Fork 35
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
Add base64-encoded images support #20
base: master
Are you sure you want to change the base?
Add base64-encoded images support #20
Conversation
{field, data = "data:image/" <> _}, fields -> | ||
encoded_image = String.replace(data, ~r/^data\:image\/.*;base64,/, "") | ||
|
||
case Base.decode64(encoded_image) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looking for something similar and maybe it's worth to have special key like Arc
something like that %{filename: filename, base64: base64}
stolen from https://github.com/stavro/arc/pull/108/files
I have exactly the same case in one of the projects and I've resolved it
by handeling API request data by decoding base64 encoded file before
passing it to the Waffle.
Probably, we can extend documentation about how to do it, but I'm not
yet sure about should we make it as a scope of waffle_ecto library.
Feedback is welcome.
|
@achempion, well, the first way of handling this case I can think of, is to define an ecto schema that parses params before sending it into If you ask me about a proper solution, this should be handled in the ecto-type itself ( |
When casting an image in base64-encoded format it will be casted to a binary image with generated file name.
f55bd5e
to
8f2f221
Compare
Any info on whether it's going to be merged? |
Hey guys, are there any plans to merge this PR? |
It is common case with json-api to send an image as base64-encoded string. Here goes support for this functionality.
Now when casting an image in base64-encoded format, it will be casted to a
binary image with generated file name.