The following sample code shows how to upload an object body with the resumable transfer.
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.
- Create a reference to the target file (sample.mp4).
- Create a
KiiUploader instance by calling the
uploader() method with the target file reference.
- Start uploading by calling the
If the KiiObject has an object body, uploading a new file will replace the existing object body.
onProgress() method will be called as the upload progresses. The method can reach 100% on the first call if the data size is small.
If the upload is interrupted for some reasons, it will be suspended and
SuspendedException will be thrown. In this case, you can resume the upload (For the steps to resume, see Resuming an Upload).
You might need to get rutime permissions for accessing an external storage during the object body uploading. See Getting runtime permissions for the implementation details.