-
Notifications
You must be signed in to change notification settings - Fork 53
On Android the url return by getAttachmentUri cannot be download #87
Comments
I have it working on android. I don't fully understand your post though. Are you saying that images work but pdfs do not? What url are you putting into your browser? |
Yes. I start up my app which init CBLite on emulator and get REST url which return by getAttachmentUri from debug console, then open the url in browser to check why view intent failed. When the attachment is image, the url download the image success, but when attachment is PDF browser start to download file but always stop quickly caused by failed to download file though no 404 error occurs. But if I write a react native module method to get attachment content by CBLite database API and write it to android external storage file system the PDF can be open. |
What's the exact url your using? Are you running on an emulator or physical device? And have you tried the other? What happens if you drop the attachment name (the bit after the last '/' character) from the url, do you see the underlying document? Can you send through the underlying document? Its possible the attachment didn't upload correctly which might be clear from the attachment size. What is the output if you CURL or wget the url? Whats the http status code? 404? 500? Have you tried on iOS? |
Test that physical device failed also and I've verified that I can get correct PDF input stream by CBLite database api doc.getCurrentRevision().getAttachment(pdfname).getContent() after uploaded. I've not tried IOS, verified that get document REST url works in emulator browser (JSON shows it has attachments of image/png and application/pdf type) and image type attachment REST url works until I upgrade couchbase-lite-android to 1.3.1-30 (1.2.1 still doesn't work), but PDF still failed in 1.3.1-30, so I think the issue is in REST api implementation of couchbase-lite-android. |
To easily reproduce this issue just use Linking.openURL(uri). |
I save a PDF file with content type application/pdf as attachment by saveAttachment api (both tried name with postfix ".pdf" or none postfix) and it success. But when I try to open the uri return by getAttachmentUri in browser or PDF reader or by Linking, it fails on cannot download file. But test that image files such as png and jpg can be download, the PDF file disk size is about 1M.
I wonder whether the REST api flush an attachment http response correctly.
The text was updated successfully, but these errors were encountered: