I am using Retrofit API to access my Laravel site data. I am not able to display images in my android app.
Here is my Laravel code to save images in my Laravel site.
$path = 'images/no-thumbnail.jpeg';
if($request->has('thumbnail')){
$extension = ".".$request->thumbnail->getClientOriginalExtension();
$name = basename($request->thumbnail->getClientOriginalName(), $extension).time();
$name = $name.$extension;
$path = $request->thumbnail->storeAs('images', $name, 'public');
}
Here is the API response for the Products tabel.
[{"id":1,"user_id":"1","title":"White T shirt","description":"White T shirt small size","categorie":"1","price":"50","discount_price":"0","thumbnail":"images\/81vzc0ciKwL._AC_UX679_1619280040.jpg","slug":"white-t-shirt","options":null,"featured":"0","status":"0","created_at":"2021-04-24T16:00:40.000000Z","updated_at":"2021-04-24T16:00:40.000000Z","deleted_at":null}]
The response of the image is this "thumbnail":"images/81vzc0ciKwL._AC_UX679_1619280040.jpg"
For my android app, I am using Picasso here is the code.
Picasso.get().load(shopesModel.getThumbnail()).into(holder.shopImg);
But still, I am not getting images in my android app. I am getting other fields of the product table.
Here is the screenshot of the app
Where should I change my code. Laraval or change my app code so that I can get images from Laravel.
Since your json response doesn't have qualified url in thumbnail
"thumbnail":"images\/81vzc0ciKwL._AC_UX679_1619280040.jpg"
There two ways you can fix
1.best solution is to send full url image path from server side
2.hardcoding base url in your android and append to Picasso
"thumbnail":"https://urdomain/storage/images/81vzc0ciKwL._AC_UX679_1619280040.jpg"
or
String baseUrl="https://urdomain/storage/";
Picasso.get().load(baseUrl+shopesModel.getThumbnail()).into(holder.shopImg);
Related
I'm trying to parse an img src that is featured on a website and include it into my app. I'm using the flutter package Web Scraper, this is the code I've tried so far:
final webScraper = WebScraper('https://tiktok.com');
if(await webScraper.loadWebPage('/#$enteredUsername')){
tiktokProfilePictureURL = webScraper.getElement('img', ['src']);
print(tiktokProfilePictureURL);
}
The image I'm trying to get the URL from is the profile picture of the account, as shown in the screenshot below.
When I look into the code of the website it provides the link to the website image but when I try to parse this in web scraper it can't seem to find it.
This is the WebScraper output:
As you can see it finds various .svg images but not the .jpeg profile picture I'm trying to find.
Or maybe there is another way to parse this image src url? Any suggestions? Thanks.
When I used volley to load data in android,I have a trouble.I used volley load googlemaps.
This is url:
http://maps.google.com/maps/api/geocode/json?address=No%204,%20Ng%C3%B5%20151B%20Th%C3%A1i%20H%C3%A0,%20L%C3%A1ng%20H%E1%BA%A1,%20%C4%90%E1%BB%91ng%20%C4%90a,%20H%C3%A0%20N%E1%BB%99i,%20Vietnam
1.In device >5.0.Volley loads it.
2.In device <5.0 like this: AsusZ002-Android:4.4.2,Htc-Android:4.2.2.Volley can't load it.
The bug is:
"Unexpected response code 400 for http://maps.google.com/maps/api/geocode/json?address=No%204,%20Ngõ%20151B%20Thái%20Hà,%20Láng%20Hạ,%20Đống%20Đa,%20Hà%20Nội,%20Vietnam"
Although a paste in website responses as json success.
Can you answer my questions?Thanks for having look at it.
Try to use URL encoder before loading it like so :
String url = http://maps.google.com/maps/api/geocode/json?address=No%204,%20Ng%C3%B5%20151B%20Th%C3%A1i%20H%C3%A0,%20L%C3%A1ng%20H%E1%BA%A1,%20%C4%90%E1%BB%91ng%20%C4%90a,%20H%C3%A0%20N%E1%BB%99i,%20Vietnam;
String formattedUrl = URLEncoder.encode(url, "utf-8");
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.
I have to upload an image from Android device to a web app written in Python and Django. For storing images, I have made use of easy thumbnails.
What I have done so far is convert the image to base64 string to and post it to server. Well this is working perfectly, also if I write the base64 string to png image file it goes smoothly.
Now, I want to save it to the database as far as I know, easy thumbnails save the actual file to some location on server within the app file structure, and saves a link to same in database.
I am not understanding, how do I save the base64 string I receive in POST to my database.
My Model:
class Register(models.Model):
image = ThumbnailerImageField(upload_to=filename, blank=True, null=True, max_length=2048)
def filename(inst, fname):
f = sha256(fname + str(datetime.now())).hexdigest()
return '/'.join([inst.__class__.__name__, f])
The image is not stored in the db. It is stored to disk. Only a reference to the file is stored in the db.
def Article(models.model):
image = models.ImageField(...)
Somewhere you create a new object:
from django.core.files.base import ContentFile
obj = Article()
data = base64.b64decode(encoded)
# You might want to sanitise `data` here...
# Maybe check if PIL can read the `data`?
obj.image.save('some_file_name.ext', ContentFile(data))
obj.save()
hello am trying to get images from an album from picasa in an android app. I tried creating an album and the album was created successfully however there is something wrong when i try to get the images in the album. Please find below my code:
PicasawebService myService = new PicasawebService("myApp");
myService.setUserCredentials("username", "password");
URL url = new URL ("https://picasaweb.google.com/data/feed/api/user/myusername/albumid/myalbumid");
AlbumFeed feed= myService.getFeed(url, AlbumFeed.class);
List<MediaContent> l;
for(PhotoEntry photo : feed.getPhotoEntries()){
l= photo.getMediaContents();
return l.get(0).getUrl().toString();
}
the for loop is not being entered but when i check the size of the feed and it shows me the correct number of images in the album. I got the code from google developers guide:(https://developers.google.com/picasa-web/docs/2.0/developers_guide_java#listalbums)
NB: i tried the same exact code in a desktop app and worked perfectly.
Thank you
EDIT: The problem is that the ALbumFeed is returning entries of class GPhotoEntry and not PhotoEntry. I searched online and the solution was to include the gdata-photos-meta.jar in my library which was already included...Any idea?
google's GData doesnt work with android. You should use google Client api and they say that there is a running sample for picasa on android.