1

{"bucketName": "documents", "chunkSize": 261120, "contentType":"image/png", "encoding": "7bit", "fieldname": "Files", "filename":"profile5.png", "id": "62e8c15571dc52ad4c47de2c", "md5": null,"metadata": null, "mimetype": "image/png", "originalname": "profile5.png", "size": 10072, "uploadDate":"2022-08-02T06:16:54.079Z"}. this data converted into base64 data { eyJmaWVsZG5hbWUiOiJGaWxlcyIsIm9yaWdpbmFsbmFtZSI6InByb2ZpbGUucG5nIiwiZW5jb2RpbmciOiI3Yml0IiwibWltZXR5cGUiOiJpbWFnZS9wbmciLCJpZCI6IjYyZjc3NWIwNGVmNTkyYjAzYWIwYWU5ZCIsImZpbGVuYW1lIjoicHJvZmlsZS5wbmciLCJtZXRhZGF0YSI6bnVsbCwiYnVja2V0TmFtZSI6ImRvY3VtZW50cyIsImNodW5rU2l6ZSI6MjYxMTIwLCJzaXplIjozNjE0LCJtZDUiOm51bGwsInVwbG9hZERhdGUiOiIyMDIyLTA4LTEzVDA5OjU4OjA5LjIwNloiLCJjb250ZW50VHlwZSI6ImltYWdlL3BuZyJ9 }. and then in react native my image as { <Image style={{width: 50, height: 50}} source={{uri:data:image/png;base64,${source}}}/>} source is the base64 data but image not shown plzz any one help me i am stuck in this almost 2 weeks :(.thanks in advance:)

Durgadevi
  • 11
  • 3

1 Answers1

0

As your converted Base64 not an image, You cannot convert into image.

Your Base 64 is text. So you just create a text field and assign the value to it.

Anand
  • 4,355
  • 2
  • 35
  • 45
  • your answer is correct but i want to view as a image not a text. this data stored in backend (mongodb using gridfs in nodejs). – Durgadevi Aug 22 '22 at 05:19
  • What's the use of viewing the text as image – Anand Aug 22 '22 at 05:23
  • {"bucketName": "documents", "chunkSize": 261120, "contentType":"image/png", "encoding": "7bit", "fieldname": "Files", "filename":"profile5.png", "id": "62e8c15571dc52ad4c47de2c", "md5": null,"metadata": null, "mimetype": "image/png", "originalname": "profile5.png", "size": 10072, "uploadDate":"2022-08-02T06:16:54.079Z"} if its my profile image i want to display this in my app as a image – Durgadevi Aug 22 '22 at 06:58
  • For that you need to check your base64 file type, if your base64 is text then set into textfield if your base 64 is an image you should set into iamgeview – Anand Aug 22 '22 at 07:04
  • first find out which type of your base64 is – Anand Aug 22 '22 at 07:05
  • https://stackoverflow.com/q/25763533/11789675 – Anand Aug 22 '22 at 07:06