-
Notifications
You must be signed in to change notification settings - Fork 14
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
Adds support for base64 Files #95
base: master
Are you sure you want to change the base?
Conversation
if(this.isBase64(file)){ | ||
const newfile = this.dataURItoBlob(file); | ||
// file = `${URL.createObjectURL(blob)}`; | ||
const fname = `${this.uuidv4()}.png`; |
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 don't like that .png
is hardcoded after the filename. (We might want to add support for non-image files later.)
|
||
saveFile(name) { | ||
const snakeName = camelToSnake(name); | ||
|
||
if (this.__fileChanges[name]) { | ||
const file = this.__fileChanges[name]; | ||
|
||
// debugger; |
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 will just remove this useless line.
@action | ||
setInput(name, value) { | ||
invariant( | ||
this.__attributes.includes(name) || | ||
this.__activeCurrentRelations.includes(name), | ||
`Field \`${name}\` does not exist on the model.` | ||
); | ||
this.isBase64File = false; |
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.
Why do we need this? It looks like this value is never read.
Also, I don't believe this variable makes sense: what should it be when the model has both a regular file field and a base64 file field? The current implementation seems to base this decision on just the type of the last file field.
This PR adds support for handling base64 encoded file fields.