-
Notifications
You must be signed in to change notification settings - Fork 53
Unable to access attachments in android #92
Comments
Indeed there's an issue when passing the URL to an attachment as |
I realize the docs and PR talk about how to persist an attachment but not how to read it. This comment should help in reading the attachment and loading it in an image tag. #11 (comment) |
Does your image work on iOS? If so then its likely that problem is that (currently) android does not allow basic auth parameters in the url, and does not accept any sort of auth header for image loading. Have you tried uploading something else, like a text document? I imagine if you looked at the logs you might notice some 401 (not authorised) errors being returned from the android listener. The work to add http headers to image requests is being carried out by the Facebook team, so a good fix should be in place soon. Maybe give them a thumbs up here: facebook/react-native#7791 (comment) The workaround in this project for now (although this might currently only be in the master branch - @jamiltz could be do a release?) is to set the username and password on android to null. This will mean that the listener doesn't do any authentication and your image http requests will work. The downside is the security problem. However, if you specify null, null credentials then the listener will refuse any connections that do not come from localhost - which I think is the same behaviour as the native iOS listener. |
@npomfret I am working only in android, so I can not test in iOS. And i have only tested it with images, because my app only works with images. |
If you look at the http headers in your browser what do you see? |
it is a 406 Not acceptable |
Hmm, that's odd. I think the problem is not to do with authorisation then - if it were I'd expect a 401. What does the document look like? Specifically the And what URL are you using? If you remove the attachment id from the end of the URL (assuming its there), can you see the document in your browser? |
no, i can not see in the browser , i see the white box when i authenticate. |
I'm afraid I don't understand what your saying. 'White box' doesn't mean anything to me.
... so its working? Or not? The couchbase lite url you are using should have authentication already in it in the form for a "username:password@' near the start of the url. I think step 1 you should try and view the document in your browser... Can you give an example URL you are using to view a CBL document in your browser? Can you view ANY document from your CBL database in your browser? Can you view the document that contains the attachment in your browser? If you add the attachment id onto that document URL, what happens? |
The url that i get from the attachment is http://admin:pass@localhost:5985/db/a4e0b0b1-6386-48e8-a680-9d9a78f9e0cf/photo and i get the following response
I mean if i try a fetch from the react component, i get a good response sending the auth headers, but that not the way to do it |
+1 |
+1 here, status 406 and no access to attachment @faxioman, could you please share your workaround catch code? In particular - which part of err contains attachment json? Plus one offtopic question: do you have your images pre-encoded to base64 on SyncGateway side or you attach just raw ones? AFAIU RN accepts only base64 in uri prop for , right? |
I can not access the images that i attached, i get the url for the attached image, but it does no show anything. Any idea?
The text was updated successfully, but these errors were encountered: