You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I want to provide the ability to upload and see images.
I'm sending the image as a Base64 encoded field in a JSON. Here's my controller code for creating the card with the image:
asynccreateCard({ request, auth, response }){try{constuser=auth.current.user;constcardData=request.only(["frontSide","backSide","category_id","imageFrontSide","imageBackSide"]);constcard=awaitCard.create({user_id: user.id,
...cardData,});returnresponse.json({status: "success",data: card,});}catch(error){Logger.error("Error creating card!\n",error);returnresponse.status(400).json({status: "error",message:
"There was a problem creating the card, please try again later.",});}}
And for retrieving the data:
asyncgetCard({ auth, response, params }){try{constuser=auth.current.user;constcards=awaitCard.query().where({user_id: user.id,id: params.id}).first();returnresponse.json({status: "success",data: cards,});}catch(error){console.log("Error getting card:",error);returnresponse.status(400).json({status: "error",message:
"There was a problem getting the card, please try again later.",});}}
Now on my local machine it works fine with an sqlite DB. The card gets stored and when I call api/card/<card-id> I get the following response:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I want to provide the ability to upload and see images.
I'm sending the image as a Base64 encoded field in a JSON. Here's my controller code for creating the card with the image:
And for retrieving the data:
Now on my local machine it works fine with an sqlite DB. The card gets stored and when I call
api/card/<card-id>
I get the following response:So I can just use the
imageFrontSide
and put it assrc
of an<img>
and the user can see the picture.Now when I run the same code on my "production" system with an MySQL db I somehow get the following response for
api/card/<card-id>
:Here's my
Card
schema:Can anyone help me out here?
Beta Was this translation helpful? Give feedback.
All reactions