Storing an attachment fails
See original GitHub issueHi, I tried to store an attachment as an inline attachment and also tried the db.putAttachment method. But I did not get it working. Also checked your example implementation.
I tried
var attachment = "TGVnZW5kYXJ5IGhlYXJ0cywgdGVhciB1cyBhbGwgYXBhcnQKTWFrZS" +
"BvdXIgZW1vdGlvbnMgYmxlZWQsIGNyeWluZyBvdXQgaW4gbmVlZA==";
db.putAttachment(doc._id, 'att.txt', doc.rev, attachment, 'text/plain');
But it fails with a strange message (Xcode console)
[tid:com.facebook.react.JavaScript] { [ReferenceError: Can't find variable: FileReaderSync]
line: 133952,
column: 35,
sourceURL: 'http://192.168.0.62.xip.io:8081/index.ios.bundle?platform=ios&dev=true&minify=false' }
It is the same with inline attachments. Storing documents without attachments works fine.
Tested with ios: 9.3 (ipad device and iphone 6 simulator). Did you get storing Attachments working?
Issue Analytics
- State:
- Created 7 years ago
- Comments:18
Top Results From Across the Web
5 Ways to Fix the "Attachment Failed" Error on Gmail
5 Ways to Fix the "Attachment Failed" Error on Gmail · 1. Switch Off Your Firewall · 2. Disable Your Proxy Server ·...
Read more >Attachment saving not working as expected - Outlook
Various attachment saving scenarios don't work as expected in Outlook 2016. Provides a workaround.
Read more >Fix: Signal App Error While Saving Attachment to Storage
If Signal can't save attachments, make sure the app has access to storage. Additionally, create a new storage folder for images and videos....
Read more >"An error occurred while getting content of attachment" error ...
While attempting to save file attachments from Track-It!, the following error may appear: An error occurred while getting content of attachment: FileName.
Read more >I am having a problem with attachments. I can no l...
If you're on JIRA server you might need to make sure your attachment storage isn't full. If you're on Cloud it may be...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Just for info: Others might ran in the storage limitation of Android. On Android asyncstorage has a limitation of 6 MB per default. I am also temporarily storing images for synchronization in PouchDB so this limit is reached very quickly. I overcome this by setting the maximum size when starting the app in MainApplication.getPackages() using
long size = 50L * 1024L * 1024L; // 50 MB com.facebook.react.modules.storage.ReactDatabaseSupplier.getInstance(getApplicationContext()).setMaximumSize(size);
Hi, got it working (workaround) for Base64 strings but not for Blobs yet.
The problem is in pouchdb-adapter-asyncstorage/bulk_docs.js using wrong data types.
I added a check for Blob in pouchdb-binary-utils/lib/index.js in the function readAsArrayBuffer(), line 61 ff. since a Uint8Array is used and not a Blob
I also did a change in pouchdb-adapter-asyncstorage/bulk_docs.js since the method global.btoa(binData) throws an error if special characters are within the base64 or reading handling image data. Error message with global.btoa(binData):
DOMException: Failed to execute btoa on WorkerGlobalScope: The string to be encoded contains characters outside of the Latin1 range.
I just use the already available base64 string.
Change in bulk_docs.js:
I think this type checks and conversion have to be done properly in bulk_docs.js that there are no changes necessary in pouchdb-binary-utils.
Hope this helps a bit for further investigation.