How to Check if an Attachment Exists
-
To check whether a document contains a certain attachment, use the method
exists()
from thesession.advanced().attachments()
operations. -
This does not load the document or the attachment from the server, and it does not cause the session to track the document.
-
In this page:
Syntax
boolean exists(String documentId, String name);
Parameter | Type | Description |
---|---|---|
documentId | String |
The ID of the document you want to check for the attachment |
name | String |
The name of the attachment you want to check the document for |
Return Value | Description |
---|---|
boolean |
Indicates if a document with the specified ID exists in the database |
Example
boolean exists = session
.advanced()
.attachments()
.exists("categories/1-A","image.jpg");
if (exists) {
// do something
}