[PWA Camera & Microphone] How to access server side?
Forge component by Ruben Goncalves
Application Type
Reactive

Great component for PWA and Reactive apps, which I've got working fine.

I'm a little stuck as to how I can use captured audio and video server side. I'd like to either save the audio in the database, or use it to post to an API. How do I convert the object created into something I can then process?

Champion
Solution

Hey Darren,

You can call TakePictureFromCamera passing the ReturnDataURI as true. You can then pass the resulting DataURI to a server action where the picture can be saved.



The DataURI is a string with the following format:

data:image/png;base64,iVBORw0KGgoAAA
ANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4
//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU
5ErkJggg==

The Base64 is the part after the comma ","

So, in the server action:

1) Split the DataURI by the delimiter ","

2) Convert the second element of the string split (Base64) to BinaryData

3) Do what you want with the BinaryData, e.g. save it on the database



Cheers,

David

Any ideas on how to do the same with the video recording of this component - to store it as a binary into either the Local DB or Server DB?

@Darren Meldrum How can i show the current recording video using a player?


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.