Instance Method
uploadAttachment(dbName:docId:attachmentName:data:contentType:rev:eventLoopGroup:)
Uploads an attachment to a CouchDB document.
func uploadAttachment(dbName: String, docId: String, attachmentName: String, data: Data, contentType: String, rev: String, eventLoopGroup: (any EventLoopGroup)? = nil) async throws -> CouchUpdateResponse
Parameters
- dbName
The database name.
- docId
The document ID.
- attachmentName
The name of the attachment.
- data
The binary data to upload.
- contentType
The MIME type of the attachment.
- rev
The current document revision.
- eventLoopGroup
Optional EventLoopGroup for network operations.
Return Value
A CouchUpdateResponse with the new revision.
Discussion
Throws
CouchDBClientError on failure.
Example Usage:
let response = try await couchDBClient.uploadAttachment(
dbName: "myDatabase",
docId: "docid",
attachmentName: "image.png",
data: imageData,
contentType: "image/png",
rev: "currentRev"
)
print("Attachment uploaded, new revision: \(response.rev)")