By uploading a file as an object body, you can associate and manage the file with a KiiObject.
The Kii Cloud SDK supports to upload an object body with and without progress callback. To upload an object body, your web app needs to support XMLHttpRequest Level 2, FileReader, and Blob. The Titanium SDK is currently not supported.
You cannot use the object body upload feature in server code.
The following sample code shows how to upload an object body after KiiObject creation.
Here is what is happening in the sample code:
Set key-value pairs (e.g., file name, file size, and the availability of an object body) in a KiiObject as needed.
Call the save() method to create a new KiiObject on KiiCloud.
Create a blob for the target file.
Start uploading by calling the uploadBody() method.
You need to create a KiiObject with the save() method prior to uploading its object body with the uploadBody() method.
The progress callback will be called as the upload progresses. It can reach 100% on the first call if the data size is small.
Set the content type in a form of "type/subtype". The content type sent to Kii Cloud will be used when the object body is downloaded and when the object body is published and viewed on the browser.