一定時間だけ公開
一定時間だけ公開する場合は publishBodyExpiresIn()
メソッドを使います。下記は、ファイルを現時間より 1 時間の間に限定して公開したい場合のサンプルです。サンプルのように公開時間は秒で指定します。
-
// Assume that the KiiObject "object" has been instantiated. // Set the lifetime of the URL in seconds. int time = 60 * 60; try { // Publish the KiiObject. String publishUrl = object.publishBodyExpiresIn(time); } catch (IOException e) { // Handle the error. } catch (AppException e) { // Handle the error. }
-
// Assume that the KiiObject "object" has been instantiated. // Set the lifetime of the URL in seconds. int time = 60 * 60; // Publish the KiiObject. object.publishBodyExpiresIn(time, new KiiObjectPublishCallback() { @Override public void onPublishCompleted(String url, KiiObject object, Exception exception) { if (exception != null) { // Handle the error. return; } } });
基本的な手順は下記のとおりです。
- Object Body をアップロードします。
publishBodyExpiresIn()
メソッドを呼びファイルを公開します。
なお、ファイルを公開するユーザーはこの KiiObject に対する READ_EXISTING_OBJECT
アクションを許可されている必要があります(公開後の URL は、誰でも Web ブラウザから参照できます)。アクセス権限の詳細は KiiObject の ACL 設定 を参照してください。