Displaying images in img src with FILE_URI on device


#1

So, I am struggling a bit here… I am rather desperately trying to get an image saved from the camera plugin to display in an img src tag. … but alas, i cannot get it to work (and I’m slowly going insane). Thus far this is what I have:

  • Testing on an Android device
  • I have tried both the full path (ie: file:///data/user/0/com.myapp/files/filename.jpg) as well as relative path (/filename.jpg)
  • The file is confirmed to exist, because I can successfully upload it to a server
  • I have updated my CSP to include img-src * 'self' data: cdvfile: file: filesystem:
  • I do not want to use base64 because what I’m building is basically an upload queue (where 15 images could be in the queue at a time). So I want to show the image being uploaded using the filepath on the device

Has anyone by chance had similar troubles? The forums and github suggest that the CSP shoudl fix it, but it doesn’t seem to work for me… i feel like i’m missing something


#2

I realized the problem was my CSP… updated it to: default-src *; script-src 'unsafe-inline' 'unsafe-eval'; img-src 'self' data: file: filesystem: cdvfile: and it worked. Sorry for the trouble!


#3

Does updating the CSP only solved your problem? I have the same issue and i am able to access the picked image file but i cant display it.

I used you CSP but still have the same issue.