I have an android application which stores image in XAMMP (i.e C:\xammp\htdocs\php\imagefolder) at the time of registration. i am using XAMMP as local server, Retrofit for network activities and glide for image processing. Image is uploading successfully and image path is being stored in DATABASE. Now when i retrieve the information from database, i want to display that image in imageView using glide but i don't understand how i do that. In JSON response i am getting the path of the image and i am also fetching the json object from json array perfectly. But the problem is image is not loading with the help of glide
This is my image path retrieved from database imagefolder/1234abc.jg
This is actual path if image in my computer C:\xammp\htdocs\php\imagefolder\1234.jpg
and this is how i tried to load the image
Glide.with(this).load(ROOT_URL+OwnerPhoto).apply(RequestOptions.circleCropTransform()).into(header_imageview);
Glide.with(this).load(OwnerPhoto).apply(RequestOptions.circleCropTransform()).into(header_imageview);
and both methods failed
have your device or emulator in same network or wifi, then
on your computer find your ip address. must be like this:
192.168.x.x or etc
and use this ip address as ROOT_URL
instead of :
ROOT_URL = "C:\xammp\htdocs\php\imagefolder\1234.jpg"
use:
ROOT_URL = "http://192.168.x.x/php/imagefolder/1234.jpg"
hope it help you.
Related
I'm trying to make my Flutter app work offline with Firebase. I store a reference to my images on Firestore and the image files on Storage. I got the Firestore part working, and I'm using a CachedNetworkImageProvider to display my images, which caches for offline use. But when I'm offline, even though the image is cached, I can't get the URL for the image, so I can't pass it to CachedNetworkImageProvider, which uses the URL as the key.
So while offline I know the image path, and I have the file stored on device, I just need a way to get the URL.
Do I need to manually store the download URLs from Storage on the device so that I can use them offline? Or is there a better way?
Code to get the URL:
// this doesn't work offline
category.url = await storage
.ref()
.child("category_images/drawable-${DeviceInfo.dpiString}")
.child(document.data["media"]["src"])
.getDownloadURL();
Code to display the image:
image: new CachedNetworkImageProvider(_category.url),
You need to save the URL too. A good place could be in that image reference you have in firestore.
The other option is to use the local file since you say you know the path, though I think referring through the URL is cleaner.
In my android application when a user login from a new device i want to download all his data from the server database that may be more than 20mb in size.This data include bitmap images that are converted to string.When a user uploads a image what i done so far is i just convert this image to bitmap and then convert it to string and then save this to database,after that this data will save to server database by syncing.If the same user login from a new device i need to take all those data from server with a webservice.Right now i am using resttemplate to load this data, but the problem is when there is more than 20mb of data that mainly contains some image data the webservice may take more time based on the image size.Is there any better way to deal with images??
You can use aws s3. The images can be saved in the s3 buckets, which provides us with the URL. While loading all the details in the app instead of loading the whole image, only the s3 URLs needed to be send. The images can be downloaded later while loading them into the imageviews using libraries like Picasso or glide.
Do not use bitmap images (what ever you mean by it) but jpg's. Dont convert them to base64 as the amount of data will increase by 30%. Dont save them in a database on your server but on the server file system as normal files.
Then just give twenly urls for twenty files to the Android client and let the Android client decide when and how to download the images from url.
Alternatively you can let your base64 encoded images in the database. Just send twenty ids or file names (for twenty files) to the Android client. Then let the Android client decide when it wants to download an image using an url with parameter id.
I try to find way to send picture from android gallery to online database server such as mySQL , but I think I should upload this IMAGE file first to server after that getting the direct image link and send this link to database mysql
any one have simple idea about that ?
You could for example encode the image in Base64, and then send it to your backend parsed as JSON via rest webservices, and store it in a BLOB field.
I need a workaround for the following task:
I have a JPG (of whatever) picture on my sd card, and I need to send it to another device in the background. How should I do that?
Best way (in theory) would be via MMS, but after a lof of searching, I can say that there is no official and trustful (and working) way to do that in the background.
Any ideas, samples, even proofs that it can be done are welcomed! All that matters is that a remote device must have access to that image.
if you want the sending to happen in background you could use android beam, but you would have to get both devices cloth together.
And as i am not sure about what u mean by background i can't be sure that thats what you want. :)
First of all you need to create a "Service" in App which will run in background and do all tasks given below. A central PHP Server required for this task. Other device can download that file by the same HTTP request method.
Convert image to base64 string--
How to convert a image into Base64 string?
you can convert byte array to suitable types- string or delimiter(, or .) separated string
Then create a HTTP request--
Make an HTTP request with android
for HTTP request create a url like this - https://www.yoursite.com/post/?code="base64 string goes here"
-Receive data in php file on your server by $_GET global array
$code = $_GET['code']
In php file convert base64 code to original image.
How to decode a base64 string (gif) into image in PHP / HTML
get image from base64 string
Maybe I explained badly my needs. An important thing I missed is that the same person has access to both device. I solved it by uploading the image to google drive.
I am working on a Android project and want to upload Bitmap images to my rails server. But I have no idea how to write the Rails models or controllers.
I find someone using MultipartEntity post to upload images and paperclip to recieve images on RoR server. I want to know how to connect the post and server (what url?) and how to write the model or controller.
I use a stupid method. I convert the Bitmap image to byte array and use Base64 method to convert it to a string. Post the string to server. When I want to get image, download the string and convert it to Bitmap.