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.
EDIT
Would like to save captured images as jpeg's to Azure Blob Storage.
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://learn.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-dotnet
Related
I am trying to sync the uploaded file to my local desktop folder during upload, but I want to sync only a few types of files.
Is there a way to do achieve this? I am unable to find anything in the API documentation.
Thanks for your time.
I'm developing a Xamarin.Forms application for Android and iOS that needs to take photos and upload its to a Server. Then, to take the photos on the client side, I'm using Xam.Plugin.Media.
But, as this plugin saves the photos in Xamarin.Forms.Image format and I need them in the System.Drawing.Image format on the Server side, first I tried to save the photo taken by Xam.Plugin.Media in a Byte array, upload it to the server and then save the Bytes array in System.Drawing.Image format, but do not work.
After, I searched for several days in the Internet how to convert the formats and I didn't find anything useful, either converting on the mobile side using Xamarin or on the Server side using C#.
Can anyone help me in this challenge?
Thanks in advance and sorry for my poor English.
Marcelo Camarate
First of all I would use MediaPicker from Xamarin Essentials rather than the outdated media plugin. Second, the FileResult you get back provides access to a Stream which you can copy to a MemoryStream ahich you can copy to a byte array with MemoryStream.ToArray() which gives you your byte[]. You can see an example on the page I link to of how to get the stream from the photo and the various docs for the other methods to find out what you need.
You can then upload the bytes however you want based on your server API.
I have tried on the Aviary SDK, is a amazing images editor tools for developer. It really save our time to develop all the function for images edit.
But, one concern about the onSave handler, Aviary will send the edited image to their cloud server, and host it for 72 hours. Therefore, am I right to say we have to make sure our apps has connection with the Adobe cloud? This cloud be a problem if abode cloud service down or Adobe stop the service?
So, anyway to customize the 'onSave' handler for Aviary?
Thanks.
Found that if we using the Android SDK, we are able to set the withOutput, which is
withOutput(Uri)
- Sets the output location where the edited image will be saved.
But no idea for web version, for the onSave method.
I will like the following:
1. Is there an API for this?
2. If my app adds a picture, if this firebase is like dropbox (or better) can i read from the virtual folder to display the picture on the web?
Firebase does not have a built-in way to sync filesystems. You could potentially use the Firebase REST API or the Node.js client to push images into Firebase though.
Once your data is in Firebase, it's easy to pull it down into a webpage using the javascript library. I'd recommend storing the image as a base64-encoded string and setting the dataURL on an image to display it.
I checked in the API, that writing a file is only in Flex Air.
Despite of that, is there still a way in Flex to write a file on the server or on the client machine ?
More concretely, it's because I have a String and I will decode it by mx.utils.Base64Decoder
to a doc. And I need to open it by Word directly on the client side, or write it on the server and return the link to the client for downloading.
Thanks
I'm doing something similar - I have built a custom grid in Flex that contains an additional button on it that allows the user to open the data up in Excel. I've done this by writing a function in PHP on the server which my Flex speaks to. This creates the CSV file on the server and the function passes the link back to the client, which in turn offers the user the chance to open the data up in Excel.
I'm using the Zend technologies to accomplish this - I recommend you take a look; they're extremely good. I used to use Flex Data Services and Java do do this but just recently switched to PHP because development time is cut down drastically as a result.
Hope this helps.
Jamie.
AIR applications run on the users' desktops. They allow you to write to the users' desktops. Nothing stops Flex/AIR applications from communicating to the server, write some files there (using a suitable backend technology) and return a link back to the user.