Publishing a File until a Specific Time

To publish a file until a specific time, use the expiresAt option. The following command publishes a file until December 21, 2099.

curl -v -X POST \
  -H "Authorization: Bearer {ACCESS_TOKEN}" \
  -H "Content-Type: application/vnd.kii.ObjectBodyPublicationRequest+json" \
  -H "Accept: application/vnd.kii.ObjectBodyPublicationResponse+json" \
  "{APP_ID}/groups/{GROUP_ID}/buckets/{BUCKET_ID}/objects/{OBJECT_ID}/body/publish" \
  -d '{"expiresAt": 4102358400000}'

As shown in the sample, specify a UNIX timestamp in milliseconds (UTC) as the expiration time. Without the expiresAt option, the URL will remain valid forever.

Kii Cloud returns a response like the following example.

< 201
< Expires: Thu, 31 Dec 2099 00:00:00 GMT
< Content-Type: application/vnd.kii.ObjectBodyPublicationResponse+json

  "publicationID" : {PUBLICATION_ID},
  "url" : "{PUBLICATION_ID}"

The URL for accessing the object body is included in the response body.

Note that a user needs to be permitted the READ_EXISTING_OBJECT action on a KiiObject to publish its object body (Once published, anyone can access the object body with the URL). See Setting a KiiObject's ACL for more information about the access rights.