-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Attachments Support #68
Comments
Any additional approaches, solutions, consideration, corrections etc. is greatly appreciated. I'll keep the issue up-to-date will all progress. |
Update: I've got both scenarios working: V8 Debug and JSC Release by using react-native-fetch-blob. I'm trying to get my fork up-to-date with my current prototype - I'll post further updates when that is completed. DirectionAfter working through some use-cases I'm starting to realize that Blob support, on a Native Device, would not be realistic to do in-memory. Moving data in-out of AsyncStorage into Device memory probably only work for small files, and probably lead to instability at any real scale. My longterm approach would be to keep Attachments stored on the filesystem and stream to CouchDB on sync. Ideally we would try to remove any in-memory loading of Attachments in this library. This could be a large shift in the direction of this library. More discussions needed. Once I get my fork updated I'll go over the code and talk about options and tradeoffs. |
I finally have a working branch that supports Attachment replication/sync in both V8 (Debug) and JSC (Release) modes. Currently tested in iOS. There are 8 failing regression tests (from the original pouchdb regression set) that I'll be fixing soon. Code is in a branch on my fork here: https://github.com/jurassix/pouchdb-react-native/tree/attachments Note: {
"dependencies": {
"pouchdb-react-native": "git://github.com/jurassix/pouchdb-react-native.git#4a44854ffa5566126d023669218dd2ee8801025e"
}
} The main enhancements are as follows:
To fully support Attachments your library must use react-native-fetch-blob. Code changes made to To use the above fork, you need to follow the install instructions from react-native-fetch-blob and then add the following code to you app: import RNFetchBlob from 'react-native-fetch-blob'
global.Blob = RNFetchBlob.polyfill.Blob
const Fetch = RNFetchBlob.polyfill.Fetch
// replace built-in fetch
global.fetch = new Fetch({
auto : true,
// now, response with Content-Type contains `image/`, `video/`, and `video/`
// will downloaded into file system directly.
binaryContentTypes : ['image/', 'video/', 'audio/']
}).build() The above code will polyfill both Fetch and Blob support in your application and Next steps:
|
@jurassix Thanks for the great work you did! If you like to chat/talk with me about the integration just ping me via Twitter. In the evening Hours Central European Time works best for me. |
@stockulus @jurassix Any new developments on this? |
@kkbhav I'm still using the fork from above for my needs. I think we should be able to move this work into an official branch and release under a tagged npm version as a first next step. Something like @stockulus I'll reach out to you via Twitter this weekend to talk about options. Moving this into a mainline branch and releasing it will go along way in getting people to help verify and find issues before we move to master. Any initial thoughts? |
@jurassix thats fine for me. Is there additional setup work needed like react-native link...? If so, I'd write some documentation. |
@stockulus Nope the only thing that is needed for attachment support is for users to follow the install instructions from react-native-fetch-blob and then add the following code to you app: import RNFetchBlob from 'react-native-fetch-blob'
global.Blob = RNFetchBlob.polyfill.Blob
const Fetch = RNFetchBlob.polyfill.Fetch
// replace built-in fetch
global.fetch = new Fetch({
auto : true,
// now, response with Content-Type contains `image/`, `video/`, and `video/`
// will downloaded into file system directly.
binaryContentTypes : ['image/', 'video/', 'audio/']
}).build() If you don't do the above |
Note, a project to watch out for in the future will be react-native-node which essentially allows us to run a node.js instance in the background of our apps (currently only supports Android.) With this project we should have many more options for handling attachments in the future. |
I am already watching this Project, would be so great, not only for this Project! |
@jurassix if you create a Pull Request agains |
@stockulus thanks for setting this up. I'm swamped with deadlines through Friday. Hopefully I'll have some this weekend to port over. Can I assume that each of the existing Right now I just have relative paths between the packages in my branch, would be best to require these from npm. |
@jurassix no stress!! I'd publish them on npm with @attachment version and write few line in the readme about it |
Hi, I'have problem when I use "npm install pouchdb-react-native@attachment" command. |
Sorry did not manage it yet, still waiting for the merged code. Try install via git link from @jurassix as soon the https://github.com/stockulus/pouchdb-react-native/tree/attachments is up to date, I'll publish it. |
@Franklin62120 @stockulus Hopefully I'll start working on the Attachment Release soon, until then let me know if you have any issues installing via Git. The only issues I've encountered is npm versions unpack the project slightly different. If you hit any issues in the interim please raise them and I'll help where I can. Again, apologies on the delays. |
Ok, thanks. It's not blocking for my project. |
@stockulus I've started working on the migration. Hopefully I'll have this completed this weekend. |
@jurassix how did it went? is attachment support stable now? |
Still in-progress, again apologies for the delay. The fork is stable, I've been using it production for 6+months. |
Hey, any updates? |
Subscribing. |
I’m still, slowly, making progress. Current status is trying to get all regression tests to pass. |
FYI: A PR that adds Blob support to RN has been finally merged: |
@craftzdog that sounds great, that makes it much easier |
@stockulus @craftzdog I knew my procrastination was purposeful ;) . Most of the changes in this issue were to get Blob support to work with fetch, so we should scrap this work in favor of RN. Guess we need to do a prototype with attachments and see if we are good. |
Any news on this? Considering PouchDB for a project but would need Attachments :) |
I've spent all day trying to get this to work any way possible, and am hitting a brick wall with being able to install the forked branch from github and get it working. If I edit my Error: Cannot find module '/home/.../node_modules/pouchdb-react-native-bundle/packages/pouchdb-react-native/setup.js' It still creates a pouch-db-react-native-bundle folder in my node_modules folder, but it doesn't have an index.js in it and can't be referenced by the code. Any help you can offer, @jurassix or @stockulus would be hugely appreciated. |
@equesteo yes I'm also experiencing this issue now. I've update the postinstall script, so the error you reached should be resolved. There are a couple other issues I'm seeing. The package is now being installed under the To resolve the module name issue, I've renamed it manually inside my node_modules to be Npm version is also important. Because this is a fork, the packages/ folder has newly added packages, that are not published to npm (pouchdb-fetch-react-native, pouchdb-adapter-http-react-native). These are npm installed via file paths, and new versions of npm create symlinks which breaks the React Native bundler in my testing. I've had to downgrade to node 6 + npm 3, I'm using nvm so it's not a pain. Again it's not ideal. Doing the above has allowed the fork to install and work. Based on the blob support now added to natively to RN's fetch, I don't think we need the fork going forward, assuming you can upgrade to the latest RN. I'm trying to put together a working example and flush out any open issues this library has to support Attachments. Let me know if you struggle with the above install suggestions, I'll do what I can to help. |
@jurassix Whats the current status of attachments? |
Any update? Would really like to use PouchDB but got to have attachments. Thanks! |
guys, any updates on this? Demand is clearly significant) |
I have not been able to test the native Blob support yet. I agree that attachments is significant, for my company the forked version has been stable in production for over a year now, and because of that I haven't had the resources to move off the fork. Luckily this quarter I'll be revamping my companies mobile offering. I'll be eager to drop the fork and work through the native Blob support during that process. |
cool! looking forward to it
thanks again,
Ilia
… On 30 Sep 2018, at 20:23, Clint Ayres ***@***.***> wrote:
I have not been able to test the native Blob support yet.
I agree that attachments is significant, for my company the forked version has been stable in production for over a year now, and because of that I haven't had the resources to move off the fork. Luckily this quarter I'll be revamping my companies mobile offering. I'll be eager to drop the fork and work through the native Blob support during that process.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub <#68 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ABoowJVGNmMdWGLjkrKyhqQyz_KAYDiPks5ugRopgaJpZM4NsMEt>.
|
We need this feature as well. Has there been any progress? Anything we could do to help? |
@alexiri the only progress I have made was to release the original fork. You should be able to use Attachments with the following:
|
@alexiri you will also need to follow this comment too: |
Hi everyone, I tried to work with Hence, I started working on my own patch to get the attachments support for react-native inspired by jurassix & stockulus implementation. People who are interested can give a try at pouchdb-adapters-rn |
@jurassix I would like to pick this up. The first step for me is simply running the PouchDB test suite in the RN environment. Looking at the comments here, it sounds like you were able to do that. How can I do this? I think just getting that running in travis would be an immense help for this project. |
I think the only special part was making sure you pull the submodule for the base project. This library used an existing test suite to validate the functionality. I'd start with the current master branch and get those running, then trying the same for the fork. All tests are not passing on the branch, lots of issues with Standard js linting etc. |
Will do, thanks. Yes, everything breaks right now T_T. The PouchDB project itself has such extensive testing capabilities (see TESTING.md) that I am wondering if they would mind a PR to support RN, as well. |
Well, I'm putting this project down again. I tried to fix the tests in this repo, but I frankly have no idea how any of it works and was completely unable to get anywhere with development on it. My next idea was to get the PouchDB tests running on the simulator via Detox, but it turns out that Detox runs the mocha code in Node and only sends interaction signals over the network to the simulator. Running Mocha programmatically was also problematic because it requires you to input the directory of tests, and in Expo there is no dynamic |
Hey, I've got it to work with minimum changes to core packages. |
Hello, |
Is there any progress on this or should we say the project is not maintained anymore? |
I will admit my time has been absorbed elsewhere in the past few months. I am looking to having my team spend some time refreshing this project in the next little while. As far as attachments go, we are not consumers of this feature, and therefore would look for contributions to help it improve. Thanks |
Thank you for your reply, I appreciate it. I will see if we can look into this and help, as it's a really important feature for us. I have looked at other solutions but PouchDB and CouchDB solve a various number of things for us. |
This issue is to act as a placeholder for work remaining to fully support Attachments.
The remaining issues are as follows:
Considerations unique to ReactNative:
(Note: these following information is based on my observations, some accuracy may be missing, please correct where appropriate. I'm still learning how the ReactNative packager works.)
Research:
postinstal
phase, where thepouchdb-binary-utils/package.json
is patched to force the ReactNative packager to chose the node versions of the library.pouchdb-adapter-http
, which in turn delegated topouchdb-ajax
. Since ReactNative runtime JSC has no support for FileReader/FileReaderSync we do not have a utility to transform aBlob
toBuffer
orBase64
. more context hereArrayBuffer
in all cases instead of returning aBlob
and be in a better situation. More research needed here.pouchdb-ajax
because it relies onrequest
which will not work in ReactNative without hacks to expose additional core node modules.Next Steps:
pouchdb-adapter-http
andpouchdb-ajax
and have created ReactNative versions of these and am experimenting with getting full support for both Debug and Release. For these versions I'm supporting onlyfetch
and always returningArrayBuffer
neverBlob
. This is getting close. However, many tests are not passing locally.pouchdb-adapter-http
. My current build hasn't made any changes except to the new pouchdb-ajax delegation library. There is currently no way to provide strategies without having direct access to the PouchDB instance. Long term this will not be maintainable without a strategy pattern in place at plugin registry. Also, there may be much better ways of injecting a different implementation, will need some direction from @nolanlawson e.g.The text was updated successfully, but these errors were encountered: