Skip to content

Fix type error when saving existing media object#2

Open
vhorzinek wants to merge 3 commits into
leonardstruck:mainfrom
vhorzinek:fix-undefined-data
Open

Fix type error when saving existing media object#2
vhorzinek wants to merge 3 commits into
leonardstruck:mainfrom
vhorzinek:fix-undefined-data

Conversation

@vhorzinek

@vhorzinek vhorzinek commented Jan 18, 2023

Copy link
Copy Markdown

To fix the type error mentioned in this issue:
#1

The problem was:
Since the media object was already existing, and potentially the image file was not changed, payload does not return a files.file object in the request object. Therefore the type error, because getPlaiceholder tried converting nothing to a base64.

To fix the error I, instead of the approach mentioned in the issue, decided to grab the existing image and generae a new buffer which can then be converted to base64 in case there is no base64 value already.

This approach in my opinion has the benefit of not having to reupload every image that might not have a base64 yet, since instead of running into an undefined from a missing upload, it just takes the existing image.

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.

1 participant