Accessing an Object Body
You can manage large data such as a file by associating it with a KiiObject. This large data is called an object body.
For example, you can store the metadata of a movie as key-value pairs in a KiiObject while associating the movie file as an object body with the KiiObject.
Kii Cloud allows you to manipulate an object body in the following ways.
Resumable transfer
You can upload and download a file as an object body. With this method, you can suspend and resume the data transfer. This feature is available with the Kii Cloud SDKs for Android and iOS and the REST API.
The Kii Cloud SDK for iOS additionally supports the Background Transfer feature of iOS. With the Background Transfer feature, you can delegate the process management to the OS and effectively transfer your data.
Transfer at once
You can upload and download a file as an object body. This simple transfer does not allow you to suspend and resume the data transfer.
Moving an object body
You can move an object body from one KiiObject to another. This feature is available with the Kii Cloud SDK for JavaScript and the REST API.
Publishing an object body
You can publish an object body so that anyone can access it via web browsers.
Deleting an object body
You can delete only an object body from a KiiObject. The KiiObject and its key-value pairs remain.
The following table summarizes the features available on each platform.
Feature | Android | iOS | JavaScript | REST |
---|---|---|---|---|
Resumable transfer | Yes | Yes *1 | - | Yes *2 |
Transfer at once | Yes | Yes | Yes *3 | Yes |
Moving an object body | - | - | Yes | Yes |
Publishing an object body | Yes | Yes | Yes | Yes |
Deleting an object body | Yes | Yes | Yes | Yes |
*1 The Kii Cloud SDK for iOS also supports the Background Transfer feature.
*2 The user program needs to handle data split in suspending and resuming the data transfer.
*3 The object body uploading and downloading are not available if you are using the JavaScript SDK with Node.js.
Notes for the object body processing
Review the following notes when you process object bodies.
Conceptually speaking, a KiiObject consists of a JSON document and an object body. However, key-value pairs and object bodies are manipulated with different APIs.
You first create a KiiObject with key-value pairs specified and then create an object body with a different API.
One KiiObject can have just one object body. You cannot store multiple object bodies in one KiiObject.
If you want to store multiple icons in one KiiObject, you can store them as key-value pairs by converting them to BASE64 data. An error will be issued if the size of the key-value pairs expressed in the JSON format exceeds 65534 characters.
As far as the data size is under the limit, this method has an advantage that you can get the BASE64 data and other data at once by querying KiiObjects.
When key-value pairs are updated in a KiiObject that has an object body, the object body remains unchanged.