
I'm trying to get Image from my Storage and catch error. How to cast this Object to Image?
Code
String currentAvatarFileId = (String) "6468811491b6bba36063Avatar";
Image currentAccountAvatarImage = (Image) storage.getFilePreview(
accountsAvatarBucketId,
currentAvatarFileId,
new Continuation<Object>() {
@NotNull
@Override
public CoroutineContext getContext() {
return EmptyCoroutineContext.INSTANCE;
}
@Override
public void resumeWith(@NotNull Object o) {
try {
if (o instanceof Result.Failure) {
Result.Failure failure =(Result.Failure) o;
throw failure.exception;
} else {
}
} catch (Throwable th) {
Log.e("ERROR", th.toString());
}
}
}
);
Error
java.lang.ClassCastException: kotlin.coroutines.intrinsics.CoroutineSingletons cannot be cast to android.media.Image

I don't think you can assign it like that. You'd have to assign in the coroutinecallback. Also, I'm pretty sure o would be a byte array so you would need to convert the byte array to image

Thanks. I convert it to byte array and it works correctly!

[SOLVED] Get Image from Storage
Recommended threads
- Can't start docker containers beacuse no...
Hi, I'm testing my app where I upload also files to appwrite storage. As I suspect, I've filled up my disk. Now I can't start Appwrite. Could I ask for help wit...
- Realtime Disconnects and Error: INVALID_...
Hi! I just want to ask here if there's any workaround with the disconnect issues we're encountering when subscribing to realtime events in react native using ex...
- Storage & Database is not allowing.
Storage & Database is not allowing to CRUD after i have logged in ? Using web SDK with next.js without any SSR or node-sdk.
