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
- [For Hiring][Remote]
I am a skilled Software Engineer with a strong background in full stack development, web, mobile, game development, and problem-solving. With experience in lead...
- Got an issue with "sdk.InputFile.fromPat...
I'm sorry if I did something wrong when I try to upload a file with InputFile.fromPath, but I can't figure what. I'm on node v.18 and node-appwrite v.13 ```` ...
- Query issue when getting the document fr...
I get an error when i try to get document from the database and use query to select only 1 column. **Error:** `java.lang.NullPointerException: null cannot be c...