Click here to Skip to main content
15,896,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Im trying to create a table that will store the reference of the image in Firebase storage! The image is being uploaded and stored in Firebase Storage but I cant create the table to reference it in my database

Here is my code:


What I have tried:

private async void UploadPhoto()
    {

        if (filePAth != null)
        {
            progressDialog = new ProgressDialog(this);
            progressDialog.SetTitle("Uploading...");
            progressDialog.Window.SetType(Android.Views.WindowManagerTypes.SystemAlert);
            progressDialog.Show();

            var images = storageRef.Child("images/" + Guid.NewGuid().ToString());
            images.PutFile(filePAth)
                .AddOnProgressListener(this)
                .AddOnSuccessListener(this)
                .AddOnFailureListener(this);
        }


    }

public async void OnSuccess(Java.Lang.Object result)
    {
        //get the logged on user so we know who made the category
        var user = FirebaseAuth.Instance.CurrentUser;

        //Link the photo in storage to database reference 
        try
        {
            var newImageDetails = storageRef.Child("images");
            Photo photos = new Photo();
            photos.categoryId = newImageDetails.Name;
            photos.photoId = newImageDetails.Name;
            photos.tagName = addTag.Text;

            if (user != null)
            {
                var uid = user.Uid;
                //set the users id to the category
                photos.uid = uid;
            }

            var firebase = new FirebaseClient(FirebaseURL);
            var item = await firebase.Child("photos").PostAsync(photos);
        }

        catch (System.Exception e)
        {

        }

        progressDialog.Dismiss();
        Toast.MakeText(this, "Successfully uploaded image", 
        ToastLength.Short).Show();
    }


When I test with breakpoints the code says that the items are null in the try catch block?

Im trying to get the reference of the newly uploaded image!
Posted
Updated 26-Aug-17 3:37am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900