Unable to get image from download url from firebase Storage

Firebase stored Download URL

As i have not reputation to directly view this image please click on link above

Now the problem is I’m successful in uploading an image to firebase Storage and getting the downloadurl.
as I save the download url along with my post data by creating a field in my firebase database

Now I want to get that url and show it into piccasso. the problem is I’m getting a null from post.downlaodurl

I have another image url field in my firebase database which doing prefect at getting url an showing it. But downloadurl is not doing it.

The code is below

StorageMetadata metadata = new StorageMetadata.Builder()
                                        .setContentType("image/jpeg")
                                        .build();

                                final User finalUser = user;
                                mStorage.child(key).putFile(filePath, metadata)
                                        .addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
                                            @Override
                                            public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                                                //if the upload is successfull
                                                //hiding the progress dialog
                                                //and displaying a success toast
                                                String downloadUrl = taskSnapshot.getDownloadUrl().toString();
                                                writeNewPost(key, userId, finalUser.username, finalUser.email,
                                                        title, body, stream, subject, userImage, downloadUrl);
                                                progressDialog.dismiss();
                                                final Handler handler1 = new Handler();
                                                handler1.postDelayed(new Runnable() {
                                                    @Override
                                                    public void run() {
                                                        setEditingEnabled(true);
                                                        Intent intent = new Intent(NewPostActivity.this, MainActivity.class);
                                                        startActivity(intent);
                                                        // [END_EXCLUDE]
                                                    }
                                                }, 1000);

                                            }
                                        })
                                        .addOnFailureListener(new OnFailureListener() {
                                            @Override
                                            public void onFailure(@NonNull Exception exception) {
                                                //if the upload is not successfull
                                                //hiding the progress dialog
                                                progressDialog.dismiss();

                                                //and displaying error message
                                                Toast.makeText(getApplicationContext(), exception.getMessage(), Toast.LENGTH_LONG).show();
                                            }
                                        })
                                        .addOnProgressListener(new OnProgressListener<UploadTask.TaskSnapshot>() {
                                            @Override
                                            public void onProgress(UploadTask.TaskSnapshot taskSnapshot) {
                                                //calculating progress percentage
                                                double progress = (100.0 * taskSnapshot.getBytesTransferred()) / taskSnapshot.getTotalByteCount();
                                                //displaying percentage in progress dialog
                                                progressDialog.setProgress((int) progress);
                                                progressDialog.setMessage("its going to destination :)");

                                            }
                                        });
                            }

This is code to database storage

My writing post code is here:-

  private void writeNewPost(String key, String userId, String username, String userEmail,
                          String title, String body, String stream, String subject, String userImage, String downloadUrl) {

    // Create new post at /user-posts/$userid/$postid and at
    // /posts/$postid simultaneously

    Post post = new Post(userId, username, userEmail, title, body, stream, subject, userImage, downloadUrl);
    Map<String, Object> postValues = post.toMap();
    Map<String, Object> childUpdates = new HashMap<>();
    childUpdates.put("/posts/" + key, postValues);
    childUpdates.put("/user-posts/" + userId + "/" + key, postValues);
    childUpdates.put("/stream/" + selectStream + "/subjects/" + subject + "/" + key, postValues);
    childUpdates.put("/posts-by-subjects/" + selectStream + "/subjects/" + key + "/subject", subject);
    isOnlne();
    mDatabase.updateChildren(childUpdates);
}

now the post java class

public class Post {

public String uid;
public String author;
public String authorEmail;
public String title;
public String body;
public String stream;
public String subject;
public int starCount = 0;
public String userImage;
public String downloadurl;
public Map<String, Boolean> stars = new HashMap<>();

public Post() {
    // Default constructor required for calls to DataSnapshot.getValue(Post.class)
}

public Post(String uid, String author, String authorEmail, String title, String body, String stream,
            String subject, String userImage, String downloadurl) {
    this.uid = uid;
    this.author = author;
    this.authorEmail = authorEmail;
    this.title = title;
    this.body = body;
    this.stream = stream;
    this.subject = subject;
    this.userImage = userImage;
    this.downloadurl = downloadurl;
}

// [START post_to_map]
@Exclude
public Map<String, Object> toMap() {
    HashMap<String, Object> result = new HashMap<>();
    result.put("uid", uid);
    result.put("author", author);
    result.put("authorEmail", authorEmail);
    result.put("title", title);
    result.put("body", body);
    result.put("stream", stream);
    result.put("subject", subject);
    result.put("starCount", starCount);
    result.put("stars", stars);
    result.put("userImage", userImage);
    result.put("downloadUrl", downloadurl);
    return result;
}

and this code for getting that url to image

 if (post.downloadurl != null) {
        if ("noAttachment".equalsIgnoreCase(post.downloadurl)) {
            attachImageView.setVisibility(View.GONE);
        } else {
            attachImageView.setVisibility(View.VISIBLE);
            Picasso.with(itemView.getContext()).load(post.downloadurl)
                    .placeholder(R.drawable.image_loading_placeholder)
                    .error(R.drawable.loading_error)
                    .into(attachImageView);
        }
    }

I had pass a string “noattachment” when there is no image attached so check the condition if post.donloadurl having it or not if having it imageview is gone if it is we show the image to imageview named “attachimageview”