Upload profile image for a user Firebase

Upload profile image for a user Firebase

By : Rabinsh
Date : October 17 2020, 03:08 PM
like below fixes the issue You can use the method getDownloadUrl() in the success listener to access the download URL:
code :
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
        Uri uri=data.getData();
        StorageReference filepath=mStorage.child("Images").child(uri.getLastPathSegment());
        filepath.putFile(uri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
            public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                Uri downloadUrl = taskSnapshot.getDownloadUrl();
private DatabaseReference newStudent;

            // etc

Share : facebook icon twitter icon
CakePHP-2.0, how can i upload an image for user profile?

CakePHP-2.0, how can i upload an image for user profile?

By : larkstack
Date : March 29 2020, 07:55 AM
should help you out No matter the framework you use, this will works to PHP.
User only upload own image to profile

User only upload own image to profile

By : Nick Beswick
Date : March 29 2020, 07:55 AM
wish help you to fix your issue This is what CanCan is for. You've got it installed, but you haven't configured it.
can :manage, Photo, user_id: user.id
How to upload and assign profile picture to user during registration with Firebase?

How to upload and assign profile picture to user during registration with Firebase?

By : NicovincX2
Date : March 29 2020, 07:55 AM
wish helps you // The code below has not been tested but it should work or at least give //you an idea of how to approach your issue
.controller('signupController', ['$scope', '$state', '$document', '$firebaseArray', 'CONFIG', function($scope, $state, $document, $firebaseArray, CONFIG) {
code :
if($document[0].getElementById("cuser_name").value != "" && $document[0].getElementById("cuser_pass").value != "" && $document[0].getElementById("fileButton").value != ""){

    firebase.auth().createUserWithEmailAndPassword(userSignup.cusername, userSignup.cpassword).then(function() {

      // Sign-In successful.
      //console.log("Signup successful");
      var user = firebase.auth().currentUser;
          var database = firebase.database();

      //Upload Profile Picture
      //Altered code from: Firebase Youtube Channel.
      //Get Elements
      var uploader = document.getElementById('uploader');
      var fileButton = document.getElementById('fileButton');

    user.sendEmailVerification().then(function(result) { console.log(result) },function(error){ console.log(error)});

        //Get File
    var file = fileButton.value; // or however way the file path can be obtained
    var storageRef = firebase.storage().ref('profilePictures/' + file.name);

     //Upload file
     var task = storageRef.put(file);

     var user = firebase.auth().currentUser;        

     //Update Progress Bar 

     function progress(snapshot){
        var percentage = (snapshot.bytesTransferred / snapshot.totalBytes) *100;
        uploader.value = percentage;

        //if percentage = 100

     function error(err){


     function complete(){

        //Obtain the URL for the uploaded photo
        var photoURL = task.snapshot.downloadURL;

          firebase.database().ref().child('/accounts/' + user.uid).set({
            name: userSignup.displayname,
            email: userSignup.cusername,
            photoURL: photoURL //add a photoURL attribute and assign it to the URL of the newly uploaded file
            password: userSignup.cpassword,
            description: "No description for this user",
            facebook: "",
            twitter: "",

      }).then(function() {
        // Update successful.
      }, function(error) {
        // An error happened.



    }, function(error) {
      // An error happened.
      var errorCode = error.code;
      var errorMessage = error.message;

      if (errorCode === 'auth/weak-password') {
         alert('Password is weak, choose a strong password.');
         return false;
      }else if (errorCode === 'auth/email-already-in-use') {
         alert('Email you entered is already in use.');
         return false;



    alert('Please enter email and password');
    return false;

}//end check client username password
Cache Firebase user profile image - web sdk

Cache Firebase user profile image - web sdk

By : Yo Mall
Date : March 29 2020, 07:55 AM
wish helps you For storage caching refer to:
code :
var Metadata = {
  cacheControl: 'public,max-age=36000',
  contentType: 'image/jpeg'
Upload image to Firebase Storage and show as Profile Image

Upload image to Firebase Storage and show as Profile Image

By : user2831455
Date : March 29 2020, 07:55 AM
should help you out I need help with uploading image to Firebase Storage. I have a profile menu in my app. When user tap on this menu he/she can see profile with their info and Profile Image. So I made it so you can select a photo from the gallery. But I need to save photo to Firebase Storage and add ref to Firebase Database by uid. In addition, the user may not have a photo, so it will be nill because nothing in Database. Look at photo and you will understand everything , For Uploading to Firebase storage
code :
let imgData: NSData = NSData(data: UIImageJPEGRepresentation((self.img_Photo?.image)!, 0.5)!)
let _:NSData = NSData(data:UIImagePNGRepresentation(((self.img_Photo?.image)!))!)
self.uploadProfileImageToFirebase(data: imgData)
func uploadProfileImageToFirebase(data:NSData){
    let randomPic = randomString(length: 10)
    let storageRef = Storage.storage().reference().child("Pictures").child("\(value(forKey: "UserUID") ?? randomPic).jpg")
    if data != nil {
        storageRef.putData(data as Data, metadata: nil, completion: { (metadata, error) in
            if(error != nil){
            guard let userID = Auth.auth().currentUser?.uid else {
            // Fetch the download URL
            storageRef.downloadURL { url, error in
                if let error = error {
                    // Handle any errors
                    if(error != nil){
                } else {
                    // Get the download URL for 'images/stars.jpg'

                    let urlStr:String = (url?.absoluteString) ?? ""
                    let values = ["photo_url": urlStr]
                    self.registerUserIntoDatabaseWithUID(uid: userID, values: values as [String : AnyObject])


func registerUserIntoDatabaseWithUID(uid:String, values:[String:AnyObject]){
    let ref = Database.database().reference(fromURL: "https://domain.firebaseio.com/")
    let usersReference = ref.child("users").child((Auth.auth().currentUser?.uid)!)

    usersReference.updateChildValues(values) { (error, ref) in
        if(error != nil){
        self.parentVC?.dismiss(animated: true, completion: nil)

Related Posts Related Posts :
  • Storage Access Framework, takePersistableUriPermission
  • How to get the margins of a View, moved to a position which isn't known at run time
  • BottomNavigationView hides when scrolling up instead of down
  • how to add imagebuttons on horizontal scroll view of tabs so as to scroll on left and right by those image buttons in an
  • How to fetch a data from the database mysql using asynctask?
  • How can I implement this view in Android?
  • Realm - insert object into specific location
  • Android Firebase storage, innerclass download to bitmap
  • `getLeft()` returns zero in `onWindowFocusChanged()`
  • Null data on resumed activity
  • Google Drive REST API : file.getCreatedTime() returns always null
  • android Transform Exception
  • Correct way to check disk space available for Android app?
  • Round up float .25
  • Android - deleting characters on button press
  • Android - one date and two time pickers in one dialog
  • Change background of particular item to a colour and other items to different colour
  • How to use horizontal view pager inside recycler view
  • Fragment is null whenever trying to reload fragment after a delete
  • Add horizontal line inside EditText
  • How to ask and accept all permissions in only one confirm alert dialog in Android 6.0
  • How to handle configuration change in Snackbar?
  • Android Studio 2.2.2 LLDB 2.2 update issue
  • Gradle build showing error when trying to add MapsActivity
  • In Android Intent why we write ActivityTwo.class in second argument?
  • Android - Connected Tests Results Directory
  • prevent partial overlapping of shape drawable stroke
  • How to rapidly prototype an image recognition application using Machine learning & neural network?
  • Volley RetryPolicy querying twice before timeout time is reached
  • Use custom RenderScript in system signed application
  • Automatic reply for whatsapp messages approach
  • Auto active/deactive Location & Data
  • error: cannot find symbol class Crashlytics and Fabric
  • SurfaceView how to Re-Create if it has been destroyed
  • Espresso idlingResource - how to register?
  • Change encoding of androidManifest.xml to UTF-8 in Android Studio 3
  • MS Syncframework 4 - no response after 5 minutes of server side processing
  • Kotlin clear an adapter
  • Parsing datetime to UTC
  • How to turn off keyboard icon at TimePicker?
  • How to make Primary key Auto increment while using Composite Primary keys in Room persistent library?
  • Passing between Activities using Intents
  • JSONObject fields in GSON class - Remains empty
  • Include headers directories for gradle generation with JNI interaction
  • ListView updates the entry only when the application is restarted again
  • SyncFailed Error:Cause: org/jetbrains/plugins/gradle/tooling/ModelBuilderService
  • minSdkVersion cannot be smaller than version 14 declared in library support-v4:26.0.0-alpha1 Manifest Merger Failed
  • Bluetooth connect works on some devices
  • How add space (e.g.height = 20dp) between searchView and dropdown list?
  • in Android studio Register New File Type Association for ttf
  • phoneGap 3.5.0 to 6.5.0 and api status was undifined
  • CountDownTimer - how to start from another method rather than Oncreate method
  • url not showing in WebView inside a Dialog
  • adjusting height of StackLayout element
  • I can't able to take my Images to new activity that are loaded from SD card
  • Paging Library invalidating data source not working
  • build.gradle warning 'avoid using + in version numbers'
  • NumberFormatException when setting SimpleDateFormat
  • How to add more work for 1 hit of "take image" button for camera app?
  • TabHost activity is not working
  • shadow
    Privacy Policy - Terms - Contact Us © soohba.com