-
Notifications
You must be signed in to change notification settings - Fork 2
Sample Code ( Firebase Object File )
dongjaekim edited this page May 1, 2021
·
3 revisions
- The path for each file is stored in the application in advance, so if you click on the 3d model by specifying a path on the firebase for each item, you can run firebaseDownload, and for PNG, save via downloadBytes to convert it to a file.
public void downloadBytes(){
FirebaseStorage storage = FirebaseStorage.getInstance(instance_dir);
StorageReference storageRef = storage.getReference();
StorageReference pathReference = storageRef.child(filepath_firebase);
final long ONE_MEGABYTE = 1024 * 1024;
pathReference.getBytes(ONE_MEGABYTE).addOnSuccessListener(new OnSuccessListener() {
@Override
public void onSuccess(byte[] bytes) {
Bitmap bit = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
ivPreview.setImageBitmap(bit);
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
// Handle any errors
}
});
}