I have a marketplace web app, where users can upload items, and of course they can also see images associated with these items. The problem is organizing the storage buckets
Apologies for poorly written (and untested) JS, but would something like this work?
// create a new push ID and update the DB with some information
var currentItemRef = itemsRef.push({
title: title,
description: description,
tags: tags,
price: price,
}).then(function() {
var storageRef = firebase.storage().ref();
// currentItemRef.name is the unique key from the DB
return storageRef.child(currentItemRef.name + '/' + imageNames[x]).putString(images[x], 'base64');
}).then(function(snapshot) {
// update the DB with the download URL
return currentItemRef.update({
url: snapshot.metadata.downloadURLs[0]
});
}).catch(function(error) {
console.error(error);
});