Im using Cloudinary along with an Android App.
Im uploading a image using:
cloudinary.uploader().upload(imagePath, ObjectUtils.emptyMap());
The problem is that I need the url to retrieve this image later. Is there any method that I can use to store the uploaded image url inside my App?
Thanks!
According to their documentation
Documentaion
This code shows
Map uploadResult = cloudinary.uploader().upload(file, ObjectUtils.emptyMap());
Uploading is performed synchronously. Once finished, the uploaded image is immediately available for manipulation and delivery.
An upload API call returns a JSON object with content similar to that shown in the following example:
{
"public_id":"tquyfignx5bxcbsupr6a",
"version":1375302801,
"signature":"52ecf23eeb987b3b5a72fa4ade51b1c7a1426a97",
"width":1920,
"height":1200,
"format":"jpg",
"resource_type":"image",
"created_at":"2013-07-31T20:33:21Z",
"bytes":737633,
"type":"upload",
"url":
"http://res.cloudinary.com/demo/image/upload/v1375302801/tquyfignx5bxcbsupr6a.jpg",
"secure_url":
"https://res.cloudinary.com/demo/image/upload/v1375302801/tquyfignx5bxcbsupr6a.jpg",
"etag":"1adf8d2ad3954f6270d69860cb126b24"
}
The response is automatically parsed and converted into a Map.
Related
I'm using the Firebase authentication module in react-native with native-cli. On sign up, I'm uploading an image using react-native-document-picker. After selecting an image from the gallery it will look like this:
{
"fileCopyUri":"content://com.android.providers.media.documents/document/image%3A33077",
"name":"IMG-20211005-WA0007.jpg",
"size":67094,
"type":"image/jpeg",
"uri":"content://com.android.providers.media.documents/document/image%3A33077"
}
and using this function to upload it on firebase:
auth().currentUser.updateProfile({
displayName:fullname,
photoURL:JSON.stringify(pic),
})
now when I get it like this:
const fireUser = auth().currentUser;
console.log(JSON.parse(fireUser.photoURL))
It displays the image on the screen but when I quit the app and again open or log in to the app it's not displaying the image but I'm having pic in photoURL.
Is it possible to convert file?
{
"fileCopyUri":"content://com.android.providers.media.documents/document/image%3A33077",
"name":"IMG-20211005-WA0007.jpg",
"size":67094,
"type":"image/jpeg",
"uri":"content://com.android.providers.media.documents/document/image%3A33077"
}
into URL?
What am I doing wrong?
The URL you're passing to updateProfile is a local URL on your Android device, which won't work. To ensure the profile is visible, upload the local file to a public place in the cloud, and then pass the URL for that location to updateProfile.
For example, you can upload the file to Cloud Storage with Firebase, then get the download URL that provides read-only, public access to it, and store that in the user profile.
I am developing story feature app like instagram or whatsapp but I got stuck somewhere. I am getting image thumbnail from server as URL but when I try to use it . It take some time to load that image.So I want to Load add thumbnail images from url in previous activity and then set that thumbnail from cache.How I can store url images in cache Hashmap or arraylist to use them in next activity.Please help.I am in trouble right now.
You can use Glide for catching the image from URL.
I am creating an android application. I am getting the response from server in json format. I ma parsing the json response. When I get the content it may contain image or video link. How can I check whether image or video link is present in the content and download the corresponding image or video and display it in my application. I am aware f downloading images and displaying them, but I am not aware of how to check for the link.
My response is in the following format:
<p class='para-inside-post'> cool panda <a class='handler_name' href='/#12'>#12</a> </p><img class=\"post-img-tag\" postcreatorid=\"56332edfad441746cbd15000\" src=\"https://image.jpg\" height=\"430px\" width=\"430px\">"
I am parsing the text as shown below:
postContentSplit = Html.fromHtml(content).toString();
Similarly, how can I do the same for images and videos?
All suggestions are welcome. Please help me come out of this issue.
Use Patterns in order to check url validity
Patterns.WEB_URL.matcher(potentialUrl).matches()
It will return True if URL is valid and false if URL is invalid.
It's weird, but till yesterday i was able to get the gplus user's image in my app but today it's just not coming. Nothing simply blank. And just appears at some time..
I have been using the urls specified in Getting Google+ profile picture url with user_id but these all seem invalid and gives 404 Error.
https://plus.google.com/s2/photos/profile/116018066779980863044?sz=100
If anybody could help me out why this weird behaviour. The Profile pic appears seldom. But mostly it's blank.
The image URL you were using was never a public API and so there was no guarantee it would continue to work. The recommended practice going forward is to use the people.get API method to get the profile => image => url value instead. That URL could stop working if the user changes their avatar so you might want to fetch the actual image and cache it on your own servers.
I think the Image url has been updated.
Inorder to get that, we can use the PlusClient objects methods:
imageURL = mPlusClient.getCurrentPerson().getImage().getUrl()
{Returns a String - Image Url as String}
imageURL = mPlusClient.getCurrentPerson().getImage()
{Returns an instance of Image object}
I used graph API Json Response of Facebook Wall Post Images and display in my APP i successfully got it. But the wall images look very Blur how to resolve? i used this code for get wall picture
URL url=new URL(hashMap.get("picture_url"));
bitmap=BitmapFactory.decodeStream(url.openConnection().getInputStream());
((ImageView)view.findViewById(R.id.imageView_FullImage)).setImageBitmap(bitmap)
The Facebook Graph API as well as the FQL data set always returns the Picture URL of a thumbnail. If you look at the URL it returns, it will have one of these ending (right before the image extension .jpg, .png, etc) _t., _a.. For example, if the URL is to a JPG file, it could have an ending _t.jpg
The idea is to swap the ending and choose a normal size for the image that is returned. To do this, use the code below that will replace the endings with the one for normal sized images (that should have the _n.)
By the way, I don't think the tag you are looking for is picture_url. It should be just picture. But regardless, get the source URL as shown below, replace the endings and then pass it to the this line in your code:
// THIS SHOULD BE AFTER THE if....else code block
bitmap=BitmapFactory.decodeStream(url.openConnection().getInputStream());
CODE TO REPLACE THE VARIOUS THUMBNAIL IMAGES: By the way, this is production code and works perfect.
String PICTURE_URL;
String getPicture = JOFeeds.getString("picture");
if (getPicture.contains("_t.")) {
PICTURE_URL = getPicture.replaceAll("_t.", "_n.");
} else if (getPicture.contains("_a.")) {
PICTURE_URL = getPicture.replaceAll("_a.", "_n.");
} else if (getPicture.contains("_s.")) {
PICTURE_URL = getPicture.replaceAll("_s.", "_n.");
} else if (getPicture.contains("_q.")) {
PICTURE_URL = getPicture.replaceAll("_q.", "_n.");
}
Note: However, in some cases, like a Video preview or a Link preview, it will not always have a bigger image available. Nothing much you can do about it nor can Facebook I suspect. These typically come from posts that are shared by users from other websites.