简体   繁体   English

Xamarin FirebaseStorage 上传图片

[英]Xamarin FirebaseStorage upload image

I can't figure out how to upload an image to FirebaseStorge.我不知道如何将图像上传到 FirebaseStorge。

 var storageRef = FirebaseStorage.Instance.Reference.Child(FilePaths.FIREBASE_IMAGE_DIR + "/" + auth.CurrentUser.Uid + "/photo" + (count + 1));`

There are 3 options:有3个选项:

storageRef.PutStream(); storageRef.PutFile(); storageRef.PutBytes(); 

FilePath = "/storage/emulator/0/Pictures/...."

How can I convert this file to be able to upload it in firebase.如何转换此文件以便能够将其上传到 firebase。 I'm new in Xamarin and I can't understand how it works.我是 Xamarin 的新手,我不明白它是如何工作的。

尝试阅读这篇文章,我用他的解释来做同样的事情,而且效果很好: https : //www.c-sharpcorner.com/article/xamarin-android-image-uploading-to-firebase/

StorageReference storageReference=null;存储参考存储参考=空;

        if (fileBytes != null)
        {          
            storageReference = FirebaseStorage.Instance.GetReference("postImages/"+"123");
            storageReference.PutBytes(fileBytes)
                .AddOnSuccessListener(taskCompletionListeners)
                .AddOnFailureListener(taskCompletionListeners);
        }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM