Well, kind of another step. I had been stuck on the view controller for preferences where users can select an image (book) and upload it. With help, I was able to put a button to select a picture (using image picker) and then it was supposed to upload the image to Firebase Storage. Selecting a picture part worked (to a point), but then it would crash. The progress bar would never show any progress meaning the picture wasn’t being uploaded. There’s always a problem. I couldn’t move on to randomly generating images from Firebase if I couldn’t get the images into Firebase in the first place. So I was stuck for a couple of weeks.

Last night through, simply through googling and some minor edits, I was able to get a picture to be saved to Firebase storage. Yeah!!!

Still, it is not completely solved. Images are currently only being saved in one place meaning I can’t currently save two pictures in my Storage bucket. Any new picture overwrites the existing picture.

At least the progress bar is working and it is cool to see uploaded images appear in Firebase 🙂

Next I took the code from my Udemy class (Rob Percival) to randomly generate images from Firebase to display to users. Unfortunately, Rob uses Parse rather than Firebase so I have to figure out how to customize the code to make it appropriate for me. See code below:

func updateImage() {

Let query = PFUser.query()

Query?.limit=1

Query?.findObjectsInBackground(block: { (objects, error) in

For object in users {

If let user = object as? PFUser {

Let imageFile = user[“photo”] as! PFFile

imageFile.getDataInBackground(block: { (data, error) in

if let imageData = data {

self.imageView.image = UIImage (data: imageData)

}

}

}

}

}
If you have any insight on the above problems, please share. In the meantime, today I expect to be working primarily on building a blank table view for one of my view controllers. Wish me luck!

Advertisements