I am trying to find an proper way of saving images in a motoko canister, I have been using an images type like this:
public type images = {
image1 : [Nat8];
image2 : [Nat8];
image3 : [Nat8];
};
I was saving images well, I just had to canvert them to a blob after querying them in my react and then display them, but the problem is that the loading time was very long because of the images, I noticed this because when I didn’t put actual images but just rundom numbers in canding ui, and then some text on other fields which this images type is part of, the querying was just almost instant, but when I save actuall images, the querying time was about 12 seconds at average, sometimes even 15, is that normal?
I then tried to change the Nat8 to a Blob, I was thinking that maybe since the Blob is more compact it can somehow help with the loading time, I set like this:
public type images = {
image1 : Blob;
image2 : Blob;
image3 : Blob;
};
But the Blob type is working almost as identical with the nat8, I converterd my image files in my react component to blobs so I can send them to the canister as blobs but still function is only accepting Nat8 values just as I was doing with the Nat8.
So is there any other way I can use to save images with in a motoko canister that will have a faster querying time? I was using a Trie, and then used a HashMap, but the slow querying time is just the same.
Thank you.
Maybe it is the iter? That doesn’t sound right, but you can test by creating a function that pre calls the array and store sit in another variable…then serve that variable directly…see if there is a difference.
Interesting, then it’s not the canister that takes that long. Something in js does that accepts and deserializes the return value. Maybe someone familiar with those js libraries can look into it.