class Attachment (View source)

An attachment is a special embedded document that exists inside CouchDB.

It is created inside the "Attachments" object for each attachment that is found.

TODO: This is a very inefficient first version implementation that saves both binary and base64 data of everything if possible to ease the API.

Methods

string
getContentType()

Get the content-type of this attachment.

int
getLength()

Get the length of the base64 encoded representation of this attachment.

string
getRawData()

Get the raw data of this attachment.

string
getBase64EncodedData()

No description

isLoaded()

No description

int
getRevPos()

Number of times an attachment was alreaady saved with the document, indicating in which revision it was added.

string
toArray()

Attachments are special in how they need to be persisted depending on stub or not.

static Attachment
createFromBinaryData(string|resource $data, string $contentType = false)

Create an Attachment from a string or resource of binary data.

static Attachment
createFromBase64Data(string $data, string $contentType = false, int $revpos = false)

Create an attachment from base64 data.

static Attachment
createStub(string $contentType, int $length, int $revPos, Client $httpClient, string $path)

Create a stub attachment that has lazy loading capabilities.

Details

string getContentType()

Get the content-type of this attachment.

Return Value

string

int getLength()

Get the length of the base64 encoded representation of this attachment.

Return Value

int

string getRawData()

Get the raw data of this attachment.

Return Value

string

string getBase64EncodedData()

Return Value

string

isLoaded()

int getRevPos()

Number of times an attachment was alreaady saved with the document, indicating in which revision it was added.

Return Value

int

string toArray()

Attachments are special in how they need to be persisted depending on stub or not.

TODO: Is this really necessary with all this special logic? Having attahments as special case without special code would be really awesome.

Return Value

string

static Attachment createFromBinaryData(string|resource $data, string $contentType = false)

Create an Attachment from a string or resource of binary data.

WARNING: Changes to the file handle after calling this method will NOT be recognized anymore.

Parameters

string|resource $data
string $contentType

Return Value

Attachment

static Attachment createFromBase64Data(string $data, string $contentType = false, int $revpos = false)

Create an attachment from base64 data.

Parameters

string $data
string $contentType
int $revpos

Return Value

Attachment

static Attachment createStub(string $contentType, int $length, int $revPos, Client $httpClient, string $path)

Create a stub attachment that has lazy loading capabilities.

Parameters

string $contentType
int $length
int $revPos
Client $httpClient
string $path

Return Value

Attachment