Module couchdb_attachments
The
couchdb_attachments
module contains functionality listed under CouchDB API
Reference section 1.4.2.
Description
The couchdb_attachments
module contains functionality listed under CouchDB API
Reference section 1.4.2.
CouchDB documents can have attachments just like an email message can have attachments.
An attachment is identified by a name and includes its MIME type (or Content-Type) and the
number of bytes the attachment contains. Attachments can be any data. It is easiest to think
about attachments as files attached to a document. These files can be text, images, Word
documents, music, or movie files.
Function Index
delete/3 | delete a document attachment. |
delete/4 | delete a document attachment. |
get/3 | Get a document attachment. |
get/4 | Get a document attachment. |
get_stream/3 | Get a document attachment streaming. |
get_stream/4 | Get a document attachment streaming. |
put/4 | put an attachment. |
put/5 | put an attachment. |
send/2 | send an attachment chunk Msg could be Data, eof to stop sending. |
stream/1 | fetch an attachment chunk. |
Function Details
delete/3
delete(Db, Doc, Name) -> any()
Equivalent to delete(Db, Doc, Name, [])
.
delete a document attachment
delete/4
delete(Db::db(), Document::map(), Name::binary(), Options::list()) -> {ok, term()}
delete a document attachment
get/3
get(Db::db(), Doc::map(), Name::binary()) -> {ok, binary()} | {ok, map()} | {error, term()}
Equivalent to get(Db, DocId, Name, [])
.
Get a document attachment
get/4
get(Db::db(), Doc::map(), X3::binary(), Options::list()) -> {ok, binary()} | {ok, map()} | {error, term()}
Get a document attachment
Option = #{<<"range">> => <<"0-19">>};Option above will allow you to only fetch the first 19 bytes of the attachment.
get_stream/3
get_stream(Db::db(), Doc::map(), Name::binary()) -> {ok, binary()} | {ok, map()} | {error, term()}
Equivalent to get_stream(Db, DocId, Name, [])
.
Get a document attachment streaming
get_stream/4
get_stream(Db::db(), Doc::string(), X3::string(), Options::list()) -> {ok, binary()} | {ok, reference()} | {error, term()}
Get a document attachment streaming
Option = #{<<"range">> => <<"0-19">>};Option above will allow you to only fetch the first 19 bytes of the attachment.
put/4
put(Db, Document, Name, Body) -> any()
Equivalent to put(Db, Document, Name, Body, [])
.
put an attachment
put/5
put(Db::db(), Document::map(), Name::binary(), Body::binary(), Options::list()) -> {ok, term()}
put an attachment
Body::body(), Option::optionList()) -> {ok, iolist()} optionList() = [option()] option() = {rev, string()} | {content_type, string()} | {content_length, string()} body() = [] | string() | binary() | fun_arity_0() | {fun_arity_1(), initial_state(), stream} initial_state() = term()send/2
send(Ref, Msg) -> any()
send an attachment chunk Msg could be Data, eof to stop sending. Not tested
stream/1
stream(Ref::reference()) -> {ok, binary()} | done | {error, term()}
fetch an attachment chunk.
Use this function when you pass the stream
option to the
couchdb:fetch/4
function.
This function return the following response:
- done
- You got all the attachment
- {ok, binary()}
- Part of the attachment
- {error, term()}
- n error occurred
Made with EDoc-S