Store Content API
Edit pageThe Store API allows adding additional content to documents and store such content in the Index Storage.
The Index Storage is designed to put files in volumes much in the way Facebook’s Haystack 1 works; once there a file enters the storage it can’t really be deleted/modified from the volume, but instead, if a change is needed, a new file blob will be written to the volume. Storage is envisioned to be used when there are files you need to store which you know won’t be changing often or at all.
Assuming there is a PNG
file called Lenna.png in the working directory, lets add those to the storage
using PUT or UPDATE (if the document already exists) and passing a content
type:
PUT /assets/LennaContent-Type: image/png
@Lenna.pngAnd getting it is just a matter of retreiving it using the GET HTTP method:
GET /assets/LennaAccept: image/pngOr by visiting the link to it with your web browser: http://localhost:8880/assets/Lenna
Multi-Content Documents
Section titled “Multi-Content Documents”Use PUT or UPDATE with a different Content-Type to add new content to the
same document. For example, the following adds a PDF
and a JPEG from
files called Lenna.pdf and Lenna.jpg, respectively:
UPDATE /assets/LennaContent-Type: application/pdf
@Lenna.pdfThis time we also include the .jpg selector as a File Extension:
UPDATE /assets/Lenna.jpgContent-Type: image/jpeg
@Lenna.jpgThen you can get either of them requesting the appropriate content type in
the Accept header:
GET /assets/LennaAccept: application/pdfDefault Content Type
Section titled “Default Content Type”GET /assets/LennaAccept: *File Extension
Section titled “File Extension”If passing a file extension, the default content type is obtained from the
mime.types file (usually in /usr/local/share/xapiand/mime.types).
For example, this will return the content with image/png content type of the
document with ID Lenna:
GET /assets/Lenna.pngOr visiting the link to the PNG content with your web browser: http://localhost:8880/assets/Lenna.png
Retrieving Information
Section titled “Retrieving Information”You can get the information about the document as usual:
INFO /assets/LennaThe result (partially shown) has the available content types listed inside
data
{ "docid": 1, "data": [ { "content_type": "application/msgpack", "type": "inplace" }, { "content_type": "image/png", "type": "stored", "volume": 0, "offset": 512, "size": "462.7KiB" }, { "content_type": "application/pdf", "type": "stored", "volume": 0, "offset": 60063, "size": "676.4KiB" }, { "content_type": "image/jpeg", "type": "stored", "volume": 0, "offset": 143195, "size": "557.6KiB" } ], ...}Removing Content
Section titled “Removing Content”To remove stored content by storing an empty object:
UPDATE /assets/LennaContent-Type: image/jpegContent-Length: 0