Skip to content

[@triniwiz/nativescript-couchbase] when using getBlob I get an empty object back #52

@Itzme83

Description

@Itzme83

Hi,

I am not sure if I am doing something wrong or there is a bug which causes this behaviour. I took your demo code and added a new document via the "addItem" function which worked fine. A new document was added to my bucket and the attachment too. Then I wrote the following function to check the response of "getBlob":

getItem() {
    let document = this.db.getDocument("8a5349ce-9693-44aa-a636-5e6a2c4c48e1");

    console.log('document', document);

    let blob = this.db.getBlob("8a5349ce-9693-44aa-a636-5e6a2c4c48e1","image");

    console.log('blob',blob);
} 

The output of the console.log:

JS: document {
JS:   "id": "8a5349ce-9693-44aa-a636-5e6a2c4c48e1",
JS:   "revisionID": "2-929ca4eb1b2c4def2b458614a805b687af5f5287",
JS:   "title": "",
JS:   "created_at": "2021-05-17T13:04:51.043Z",
JS:   "image": null
JS: }
JS: blob {}

After this I checked the function "getBlob" in index.android.js of the plugin and added there a console.log too to check if the object there is empty too:

getBlob(id, name) {
    let document = this.android.getDocument(id);
    if (!document)
        return null;
    const blob = document.getBlob(name);
    console.log('blob', blob);
    if (!blob)
        return null;
    return new Blob(blob);
}

The output was:

JS: blob Blob{@0x908ca92,type=image/png,len=5109}

And now I am confused if there is a bug in the plugin or I am doing something wrong.

Activity

triniwiz

triniwiz commented on May 18, 2021

@triniwiz
Owner

So the document returns a json string that I parse to improve performance but I have some ideas how to fix that

Itzme83

Itzme83 commented on May 18, 2021

@Itzme83
Author

Sounds good to me. Thank you! I will test the behavior in the current version with iOS tomorrow (I am from Germany and its kinda late here now) and post here the results.

Also there is a compatibility problem with the Couchbase Sync Gateway if you are using the public API from outside the Couchbase Lite universe for example via cURL to add attachments (see this forum post for more informations: https://forums.couchbase.com/t/attachment-with-couchbaselite-attachment-v-s-syncgateway-admin-api-attachment/26007/6)

Would be nice to have this compatibility :-)

triniwiz

triniwiz commented on May 18, 2021

@triniwiz
Owner

Nice will try adding that

Itzme83

Itzme83 commented on May 19, 2021

@Itzme83
Author

So I tested now the behaviour with iOS and it is similar to Android. The output of the console.log in my "getItem" function is:

CONSOLE LOG: document {
    "id": "8a5349ce-9693-44aa-a636-5e6a2c4c48e1",
    "title": "",
    "created_at": "2021-05-17T13:04:51.043Z",
    "image": {}
}
CONSOLE LOG: blob {}

And in index.ios.js:

CONSOLE LOG: blob CBLBlob[image/png; 5 KB]
Jonathan64340

Jonathan64340 commented on Mar 13, 2024

@Jonathan64340

[EDIT][RESOLVED] Hello, i have the same issue.
With Android all work fine, but with iOS i get {} on return of the function getBlob(id, name);

Capture d’écran 2024-03-13 à 18 09 31

The details of code here

Capture d’écran 2024-03-13 à 18 30 26

How can i fix them ?
Thank you.

I'd been resolved my issue by changing this followings things :

  1. Regenerate CocoaPods
  2. Destroy and Create new platform iOS
  3. This changing in the following screenshot

Capture d’écran 2024-03-14 à 10 16 38

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @triniwiz@Jonathan64340@Itzme83

        Issue actions

          [@triniwiz/nativescript-couchbase] when using getBlob I get an empty object back · Issue #52 · triniwiz/nativescript-plugins