How to convert webcam blob url to base64 string - flutter

I am trying to implement a capture image functionality on the website using Flutter/dart and store it in the database in base64 format. I have successfully implemented the capture image functionality using the camera package(^0.9.4+21) but I am facing an issue while converting it in the base64 because the camera web gives a blob URL (blob:http://url:/).
Is there any way I can convert blob URL to base 64 string?
Or Is there any other better way to handle image on website?

Related

Transfer file from native and receive it in flutter

I have a kotlin app and I need to transfer an image file from native to flutter. I am new to the kotlin side but good with flutter. How should I approach this?
How about transfer image data in base64 string format,
In Kotlin side, encode the image file data into base64 format,
In Flutter side, decode the base64 string to image,
I think it is the normal way to transfer images or other files between different Languages

Best method suited to store and display small image in mongo database

how to store small images (< 2 MB)in mongodb and display the image on webpage without downloading it?
You can save it as base64 image. Base64 images is represented as string. So you can easily save and retrieve it. You will encode(in front-end) and save images as string. When you retrieve it to your front-end, you will decode and display it.

How to display the images in offline using ionic

I have a gallery module, the functionality implemented in this module as below
- getting the file path from the server using ajaxrequest
- the response will be json object of all image file path
- setting the filepath in image src attribute
As we are using ajax request, the images are loading in online mode only.
so how to implement the functionality so that images should show in offline also.
You may consider returning images as base64 string from the server and store them in a localstorage.
On the view use data-ng-src directive like this .
In your controller check if there is no connection and set base64 string from the localstorage as this: $scope.data.image_url=
After loading an image once, your best bet is going to be get a base64 representation of it, and then persisting that to disk.
Get the base64 representation of the image here:
Get image data in JavaScript?
Write the base64 data to disk using ng-cordova/ionic native and the writeFile method using the Cordova file plugin.
http://ngcordova.com/docs/plugins/file/
writeFile(path, file, data, replace)
There are some great answers here that I would like to build on...
I would suggest using PouchDB as a cache for base64 and/or Blob data after you have downloaded the original (one of my apps does the same thing with mp3 data converted to a Blob). You could then implement a method that checks the cache for the image before making a network request.
Nolan Lawson has created an excellent library for these binary conversions: https://github.com/nolanlawson/blob-util
Just save the base64 string to your PouchDB instance after the initial download, you can then check for that data before your app reaches out to the network.
Just beware of storage limits on iOS Safari (~50mb default)...

Have a static url to host a picture that i will update monthly (iPhone app)

Okay so I want to load a image from a URL in my app, however this image will need to be updated every month manually, therefore its not practical to have to submit a new update to apple every time the url changes. So does anyone no of a picture/file sharing site that would allow me keep the same URL for the image even when uploading a updated version of the image?
You can just use the same url for the image that you want presented hosted on your domain or a hosting site.
So something like
http://www.mydomain.com/appImage.jpg
That you always call to and always is the address of the relevant image. Basically the URL is just a location that you can store any image at.
Up to my knowledge, in order to achieve this you will need a static URL. So that means you'll have to buy a domain from a hosting service.
Or if not you can use Google Drive for this. But you'll have to do some more coding for this.
Try using Google Drive:
Upload a text file(*.txt) to your Google Drive and get a shareable link. Convert it to a direct download link.
Next save whatever your image as a String (base64); I have attached some interesting coding examples below.
Then give the file link to your app; download the file; read the String(base64) convert it back to image format.
When you want to update the Image convert it to a String; open the Google Drive; edit your file using Drive Notepad (Do not use
Google Docs) and simply save it Ctrl+S.
Useful Links:
Google Drive Direct Link Generator
Convert between UIImage and Base64 string
Converting between Image and Base64 string in iOS
Java BufferedImage to PNG format Base64 String
Convert image to base64 with java
Hope this helps.

How to Get UIImage from a 'Base64String' format raw image data, on iPhone?

In my application, I receive the image data from the server in a XML file. This data is of an image( .jpeg or .png or .tiff etc) which the server, converts into 'Base64String' format bytes to send to my application through the XML file. At my application side, the application stores these bytes, in the form of 'NSData' into a database.
Now, my application has to retrieve and show up the image at the later part. But I haven't been able to figure out how to get the UIImage from this 'Base64String' format raw image data?
Kindly guide me in this regard, since I'm a 'just-in' developer in the world of iPhone app development.
Thanks for reading through and I appreciate any help.
This page on the CocoaDev wiki contains several implementations of base64 decoding from strings. The NSData category at the bottom of the page is probably the simplest to integrate in your application.
From there, you can extract an NSData representation of your base64-encoded string. The NSData can be used to initialize a UIImage instance using the UIImage imageWithData: or initWithData: constructors.