Take the firebase storage download link and save it to a database string to be displayed in cardview via Picasso or similar [closed]

closed . This question needs details or to be clearer and is not currently accepting answers.

want to improve this question? Add details and make it clearer what problem is being solved by editing this post .

Closed 1 year ago .

improve this question

Good Night, guys. To doing a job I need to pick up the download URL of the image I sent pro storage, save this URL in the database to be able to display this image in cardview using the Picasso library. I can send the pro storage image, the Pro database information, but I need that link. GetDownloadURL returns a URL that looks like Picasso can't access or isn't access link like that. In storage has a link that if I put it directly in the database, Picasso shows normally, I need to take this link whenever I insert an image and save in the database, so it's only Picasso access this reference and show. This image is sent by ActivityResult, then I will even give an improvement on it, but for now it is funcinating, I just need this URL even

 @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == RESULT_OK && requestCode == GALERIA_IMAGENS) {
            Uri selectedImage = data.getData();
            String[] filePath = {MediaStore.Images.Media.DATA};
            Cursor c = getContentResolver().query(selectedImage, filePath, null, null, null);
            c.moveToFirst();
            int columnIndex = c.getColumnIndex(filePath[0]);
            String picturePath = c.getString(columnIndex);
            c.close();
            Bitmap thumbnail = (BitmapFactory.decodeFile(picturePath));

            imagemURL = mStorageRef.getDownloadUrl().toString();
            imagePath = mStorageRef.child("imagens_livros").child(selectedImage.getLastPathSegment() + ".jpg");
            imagePath.putFile(selectedImage)
                    .addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
                        @Override
                        public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                            Toast.makeText(RegistrarLivro.this, "Imagem carregada com sucesso", Toast.LENGTH_SHORT).show();
                        }
                    })
                    .addOnFailureListener(new OnFailureListener() {
                        @Override
                        public void onFailure(@NonNull Exception e) {
                            Toast.makeText(RegistrarLivro.this, "Erro! Não conseguimos enviar a imagem. Tente novamente", Toast.LENGTH_SHORT).show();
                        }
                    });
            imagem.setImageBitmap(thumbnail);
        }

Author: Lucas Gabriel, 2019-06-18