Mashiane Expert Licensed User Longtime User Jan 12, 2022 #1 Hi there I want to get an image and then perhaps cache it on a IndexDB for later use as a base64 image. I understand there are some .get methods. For this example.. B4X: const imageUrl = "https://i.picsum.photos/id/566/200/300.jpg?hmac=gDpaVMLNupk7AufUDLFHttohsJ9-C17P7L-QKsVgUQU"; (async () => { const response = await fetch(imageUrl) const imageBlob = await response.blob() const reader = new FileReader(); reader.readAsDataURL(imageBlob); reader.onloadend = () => { const base64data = reader.result; console.log(base64data); } })() Will it suffice if I just use BANano.GetFileAsDataURL? Thanks in advance. Update: BANano.GetFileAsDataURL is the key. Last edited: Jan 12, 2022
Hi there I want to get an image and then perhaps cache it on a IndexDB for later use as a base64 image. I understand there are some .get methods. For this example.. B4X: const imageUrl = "https://i.picsum.photos/id/566/200/300.jpg?hmac=gDpaVMLNupk7AufUDLFHttohsJ9-C17P7L-QKsVgUQU"; (async () => { const response = await fetch(imageUrl) const imageBlob = await response.blob() const reader = new FileReader(); reader.readAsDataURL(imageBlob); reader.onloadend = () => { const base64data = reader.result; console.log(base64data); } })() Will it suffice if I just use BANano.GetFileAsDataURL? Thanks in advance. Update: BANano.GetFileAsDataURL is the key.
alwaysbusy Expert Licensed User Longtime User Jan 12, 2022 #2 Probably, but you may come into CORS trouble as it comes from another domain. Depends on how the server is setup on their side. Upvote 0
Probably, but you may come into CORS trouble as it comes from another domain. Depends on how the server is setup on their side.