Transfer file from native and receive it in flutter - 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

Related

How to convert webcam blob url to base64 string

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?

How to copy an image to clipboard in flutter

I searched in google for how to copy an image to clipboard in flutter but I did not find any useful information. I only found in flutter documentation this:
"ClipboardData class:
Data stored on the system clipboard.
The system clipboard can contain data of various media types. This data structure currently supports only plain text data, in the text property."
https://api.flutter.dev/flutter/services/ClipboardData-class.html
Is it impossible to copy an image to clipboard in flutter right now?
I did not try and not sure if the answer is you looking for but you can give a try that first you can convert your image to Uint8List format with BASE64 decode and encode then copy it. for conversion you can check this. link
how-to-convert-base64-string-into-image-with-flutter
also check answers of this threat
how-to-send-image-through-post-using-json-in-flutter

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 change images in iphone app dynamically through XML file

My app contains some images which needs to be dynamically loaded from web server through XML file. Every time when changes done in admin console at web server it should reflect in iPhone app too through the XML file. I wrote XML file but dont know how to get used in iPhone code. I referred the following links,
how-to-retrieve-data-through-xml-in-iphone-locally-file
dynamically-pulling-images-from-xml-for-iphone-app
how-to-change-the-tabbaritem-images-dynamically-in-iphone-app
retrieving-images-to-iphone-app-through-xml
but all these links are not clear for me to understand. Kindly suggest me a way to do it.
So I assume your web server can serve an XML which includes the image in some encoded format like base64. Then you need to:
Load the file. For this, you should use NSURLConnection, e.g. as described in how-to-make-http-request-from-iphone-and-parse-json-result
Parse the XML. Instead of parsing a JSON, you need to parse your XML, so first, you need an XML-parser. Here is a comparison of XML parsers. Then you should access the element in the XML that represents your image. This step depends on your choice of the parser.
Decode the Image. Your element is probably an NSString and you want to have its binary representation as NSData. NSData has some convenience functions for this. E.g. for base64, there is the dataFromBase64String: constructor.
Create the image. That is, UIImage using the imageWithData: constructor.
Display the image. You need an UIImageView and assign to it your UIImage. Set the frame of the view and add it to your preferred subview.
It is also possible that the XML provides URLs where to get the image data. Then you have to do a new request. This should be clear by now, how to do.
Good luck.