android - Firebase Updating realtime database on successful upload of media causes stack overflow -
i trying save image download url particular user after has been uploaded cloud storage. when try update db getting stack overflow error. proper way handle ?
public void uploadartistcoverimagetocloudstorage(){ try { if (muploadedprofileimageuri != null) { storagereference riversref = mstorageref.child("images/" + muploadedprofileimageuri.getlastpathsegment()); uploadtask uploadtask = riversref.putfile(muploadedprofileimageuri); uploadtask.addonfailurelistener(exception -> { // handle unsuccessful uploads }).addonsuccesslistener(tasksnapshot -> { // tasksnapshot.getmetadata() contains file metadata such size, content-type, , download url. uri downloadurl = tasksnapshot.getdownloadurl(); string uid = firebaseauth.getinstance().getcurrentuser().getuid(); databasereference user = firebasedatabase.getinstance().getreference().child("users").child(useruid); map<string, object> userdata = new hashmap<string, object>(); userdata.put("artistprofileimage", downloadurl); user.updatechildren(userdata); }); } } catch (exception ex) { ex.printstacktrace(); } }
Comments
Post a Comment