I have a Blazor Web Assembly PWA, how do I open a devices native camera?
I am trying to write a PWA to capture and save pictures.
Would like to save captured images as jpeg's to Azure Blob Storage.
The framework enables developers to build interactive and reusable web UI in existing web technologies like C# or HTML. When it comes to grammar and syntax, the framework allows developers to use the ones of Razor and C#. Even though Blazor has accumulated only 9k+ starts on GitHub, it's still worth considering.
Blazor code can now browse local file systems and open up local files and edit them in native Windows apps.
You can achieve this with HTML input. You only need to add the attribute capture
for opening device camera straight away.
<input type="file" accept="image/*" capture>
You can have a look at the full source code here:
https://github.com/mehmettahameral/Blazor-wasm-pwa-camera
and live demo here: https://infallible-bohr-56743b.netlify.app/
--
about saving the images: it depends where do you want to save it really. If you can tell me more, I might update the solution.
Hope it helps 🤞
You can follow this tutorial: https://wellsb.com/csharp/aspnet/blazor-webcam-capture to capture camera device, stream the content, process an image.
Then, you can use the Azure Blob Storage client library v12 for .NET
to upload your images to your Storage Account.
You can find a Quickstart here: https://docs.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-dotnet
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With