Skip to content

Conversation

@kazachoc
Copy link

@kazachoc kazachoc commented Feb 6, 2021

This PR adds support for handling base64 encoded file fields.

if(this.isBase64(file)){
const newfile = this.dataURItoBlob(file);
// file = `${URL.createObjectURL(blob)}`;
const fname = `${this.uuidv4()}.png`;
Copy link

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.)

if (this.__fileChanges[name]) {
const file = this.__fileChanges[name];

// debugger;
Copy link

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.

this.__activeCurrentRelations.includes(name),
`Field \`${name}\` does not exist on the model.`
);
this.isBase64File = false;
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants