Skip to content

[Question][Help] - Downloading Attachments #157

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

Closed
mwasson74 opened this issue Jan 6, 2022 · 5 comments
Closed

[Question][Help] - Downloading Attachments #157

mwasson74 opened this issue Jan 6, 2022 · 5 comments
Labels
bug Something isn't working

Comments

@mwasson74
Copy link

mwasson74 commented Jan 6, 2022

We are using PouchDB and it is being synched/replicated to databases within CouchDB. Our pouch documents have attachments which are in turn being synched to CouchDB.

When trying to download the attachment using var file = await db.DownloadAttachmentAsync(attachment, Path.GetTempPath(), cancellationToken: cancellationToken); it is failing because the attachment.Uri is null. It seems it is null because this document/attachment was not added via the couchdb-net library and therefore InitAttachments() was not called which internally sets the Uri property.

It's very possible/likely we are doing something incorrectly on the PouchDB side and/or the CouchDB side, but any assistance here would be greatly appreciated.

Thanks!!

@mwasson74
Copy link
Author

Upon further inspection of the CouchDatabase class, I see that InitAttachments() is called when calling FindManyAsync() but not when calling FindAsync() which is what we were using to find our document. As a workaround, we are now using FindManyAsync() to get our document so that InitAttachments() gets called to set the Uri property so that we can successfully use DownloadAttachmentAsync().

Would it hurt anything if InitAttachments() was also called in FindAsync()?

Thanks,

Matt

@matteobortolazzo
Copy link
Owner

Hi, sorry the late answer.

It seems like a bug, I don't think it hurts at all but it seems strange I missed it.

Since you check the code do you mind give it a try and PR it? As I am deep is another feature right now

Thanks

@matteobortolazzo matteobortolazzo added the bug Something isn't working label Jan 12, 2022
@mwasson74
Copy link
Author

@matteobortolazzo I've cloned the repo from the master branch and created a feature branch locally but I can't get my changes pushed. This is my first PR ever to an open source project so I'm likely doing this incorrectly.

@matteobortolazzo
Copy link
Owner

No worries :) You need to fork on you own account to PR me.
So press fork, clone in you PC (dev branch) apply changes and then PR this repo

@matteobortolazzo
Copy link
Owner

v3.2.0 Released

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants