• 10
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

This question already has answers here:

storageRef.child("Uploads").child(fileName).getDownloadUrl(); returns a Task object, not Uri directly. You have to add completion listener to this task and then upload the url to your database.

final String fileName = songUri.getLastPathSegment() + "";
//final String fileName1=songUri.getLastPathSegment()+"";

final StorageReference storageRef = storage.getReference();


storageRef.child("Uploads").child(fileName).putFile(songUri)
 .addOnSuccessListener(new OnSuccessListener < UploadTask.TaskSnapshot > () {
   @Override
   public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {

     storageRef.child("Uploads").child(fileName).getDownloadUrl()
      .addOnCompleteListener(new OnCompleteListener < Uri > () {
        @Override
        public void onComplete(@NonNull Task < Uri > task) {
         if (task.isSuccessful()) {
          Uri downloadUri = task.getResult();
          reference.child("Uploads").child(fileName).setValue(downloadUri.toString()).addOnCompleteListener(new OnCompleteListener < Void > () {
           @Override
           public void onComplete(@NonNull Task < Void > task) {

            if (task.isSuccessful())
             Toast.makeText(Upload.this, "File Uploaded Successfully", Toast.LENGTH_SHORT).show();
            else
             Toast.makeText(Upload.this, "Upload failed", Toast.LENGTH_SHORT).show();
           }
          });
         } else {
          Toast.makeText(Upload.this, "upload failed: " + task.getException().getMessage(), Toast.LENGTH_SHORT).show();
         }
        }
       }
      }).addOnFailureListener(new OnFailureListener() {
      @Override
      public void onFailure(@NonNull Exception e) {

       Toast.makeText(Upload.this, "Upload failed", Toast.LENGTH_SHORT).show();
      }
  • 1
Reply Report