It works fine before I upgraded the phonegap plugin to version 1.2.1, it is just blank there on version 1.2.1, if I switched back to 1.2.0 (no other changes), the cbl attachment image can be displayed correctly.
By using Fetch (with option credentials: ‘include’, response status will be 401 without it), GET response are exactly same on both versions:
status: 200
statusText:Ok
ok: true
body: [object ReadableByteStream]
response only has one header, Content-Type: image/png
response content like: �PNG\r\n\u001a\n\u0000\u0000\u0000\rIHDR\u0000\u0000\u0002X\u0000\u0000
The cors just mean that request code and the requested resource are not from same server.
Sorry, perhaps I did not make it clear enough. My testing conclusion: even though the request get same result, cbl image can not show up when using cbl cordova plugin 1.2.1, but it can correctly show when using 1.2.0 version, there might be something difference between these two versions, but I can not find clue what to check next.
I think the response header is the indicator of what’s wrong. In my app, when I save the image to cblite, I’m specifying the header Content-Type, like “image/jpg”.
I haven’t tried to retrieve the image yet. But you might want to try specifying the Accept-Content-Type header in your request.
I’m not sure if the Android REST API supports it (I know iOS doesn’t), but it would solve this problem if you could POST to /_session and get a session cookie that way. Then the API calls wouldn’t have to use basic auth.
We moved to 1.2.1 a while ago and we had no issue with attachment at all. I understand that this information will not solve the issue you are facing. But maybe helps on its understanding.
Have you checked at the binary level (in hex) that the content you get back from 1.2.0 and 1.2.1 are strictly identicals? It might be an encoding issue…