Content Server

The iKnowBase Content Server is the web endpoint for accessing document content. The content server supports both getting (downloading) and putting (uploading) content over the HTTP-protocol.

Download content

To download content, use the HTTP GET-method with a URL identifying a specific document. The format of the URL is a set of options, separated by slashes and/or commas, ending with a trailing (and unused) readable name:

/Content/id/option,option,option,.../name
/Content/id/option/option/option/.../name

You may use either one or both of the conventions: Separate the options by a forward slash, or use the comma, or a combination of both. Also, there is no restriction on the ordering of the options.

Option Description
id A number specifying the document ID of the document whose content you want to retrieve
document.id=number Specifies the document ID of the document whose content you want to retrieve
document.guid=guid Specifies the document guid of the document whose content you want to retrieve
document.externalKey=key Specifies the external key of the document whose content you want to retrieve
docid=number Specifies the document ID of the document whose content you want to retrieve
guid=guid Specifies the document guid of the document whose content you want to retrieve
version=number Specifies the version number of the document that you want to retrieve
attr=guid Specifies the guid of a file attribute whose content you want to retrieve
cache=millis This option specified that you want the server to set HTTP-headers that request the document to be cached, if the lastChangedDate of the document matches the given millis-value.
expires=seconds Specifies that you want the server to set HTTP-headers that request the document to be cached for the specified number of seconds.
no-cache Specifies that you want the server to set HTTP-headers that request the document not to be cached.
accept=text Specifies that you want the content object converted to and returned as a pure text file. The server response will use the Mime-type �text/plain"
accept=html Specifies that you want the content object converted to and returned as an HTML file. The server response will use the Mime-type �text/html"
accept=zip Specifies that you want the content object zipped and returned as a zip file. Most useful along when downloading multiple files (see below).
content-disposition=inline Specifies that you want the server to set the HTTP header �content-disposition: inline". This is a request to the browser that the document is opened inline, inside the browser window.
content-disposition=attachment Specifies that you want the server to set the HTTP header �content-disposition: attachment". This is a request to the browser that the document is opened as an attachment, in a special application outside the browser window.
name Any name you want in the URL. The content server does in fact not use this for anything, but it is useful for providing a human readable URL, and to provide an extension for the web browser.
/Content/1234/FlightPlan.doc

The URL above will download the content of document #1234. The part “FlightPlan.doc” is not used by the content server, but may help the user to better understand what the document is about.

/Content/document.id=1234/version=2/accept=html/FlightPlan.html

The URL above will download the content of document #1234, version 2, converted to HTML. Again, the part “FlightPlan.html” is not used by the content server, but may help the user to better understand what the document is about.

/Content/document.externalKey=KEY_CURRENT_FLIGHT_PLAN/accept=pdf/FlightPlan.pdf

The URL above will download the content of a document with external key “KEY_CURRENT_FLIGHT_PLAN”, converted to PDF. Again, the part “FlightPlan.pdf” is not used by the content server, but may help the user to better understand what the document is about.

Download multiple files

You may use the Content Server to download multiple files at once. To do this, add a number of entry-parameters to the URL, where each parameter is a full specification for the Content Server. For example, use the following (one line, broken here for readability):

/Content/accept=zip/test.zip
?entry=/1111/mydocument.doc
&entry=/1111/accept=text/mydocument.text
&entry=/1111/accept=html/mydocument.html
&entry=/docid=2222/version=2/instructions.pdf

The URL above specifies the following:

Upload content

You may use the ContentServer to upload files, either as new documents or new content for existing documents.

Existing documents

To upload new content for existing documents, POST data to the Content Server, using the same URL that will server document content (shown above). You will need to be logged in for this to work.

New documents

Uploading new documents through the ContentServer works together with the UploadEvent mechanism: The Content Server receives the file, and then triggers an UploadEvent. The implementation of the UploadEvent will then handle the actual storage of the new document.

To upload new documents, POST data to the root of the Content Server. In addition to the files you upload, you may also pass a parameter “uploadParameters” that are forwareded to the UploadEvent; the content of this can be used to specify how the content should be handled.

Uploading content through the file server is most useful with new HTML5-mechanisms, where the following could be used to enable drag-and-drop of files into iKnowBase:

function startUpload(files, uploadParameters) {
   var xhr = new XMLHttpRequest();
   var data = new FormData();
   data.append("uploadParameters", uploadParameters);
   for (var i = 0; i < files.length; i++)
      data.append("file", files[i]);
   xhr.open("POST", "/private/content");
   xhr.send(data);
}