Hi, I’m referenceing post Updating Dataset from iFrame result after image capture. I
I coded it exactly like in the post but this is not working for me. The file gets created/passed as only image.jpeg. The string without the actual image! If i print it in console.log, the string “image.jpeg” gets printed. So In the dataset there is an error for mismatch of field type since the string ‘image.jpg’ is being put there instead of url. If i use Sendgrid or something to send the file even base64 etc. the actual string ‘image.jpg’ gets sent. The problem is that the wix or entire document url isn’t available from the above code but just the string.
Any way to fix?
import {sendEmail} from ‘backend/email’ ;
import wixData from ‘wix-data’ ;
$w.onReady( () => {
//TODO: write your page related code here…
$w( “#dataset1” ).onReady(() => {
$w( “#dataset1” ). new ()
});
});
export function htmlcamera_message(event, $w) {
// Add your code for this event here:
console.log( “Camera Event Start” );
let receivedData = event.data;
let dateTime = new Date();
console.log( "Camera Event will save " + receivedData);
// I try to send the image here using base64 in sendEmail but the string ‘image.jpg’ gets sent!
sendEmail(receivedData)
.then(response => console.log( "sendemail failed " + response));
// I try to insert the image into the dataset the string ‘image.jpg’ gets inserted!
let toInsert = {
“timeStamp” : dateTime,
“new_image” : receivedData
};
wixData.insert( “dataset1” , toInsert)
.then( (results) => {
let item = results; //see item below
} )
. catch ( (err) => {
let errorMsg = err;
} );
}
html component code:
#btnCapture { background-color: #566FB8; color: white; border: none; height: 100px; width: 200px; padding: 10px 20px; text-align: center; font-family: 'Arial'; border-radius: 18px; } .label { font-family: 'Arial'; } .input { font-size: 24px; }