Publishing a File until a Specific Time
To publish a file until a specific time, use the publishBodyExpiresAt()
method as shown in the following sample code. This code publishes a file until December 31, 2099. Specify a time with the Date()
method.
-
// Assume that the KiiObject "object" has been instantiated. // Set the expiration time of the URL. var expiresAt = new Date(2099, 12, 31); // Publish the KiiObject. object.publishBodyExpiresAt(expiresAt).then( function(params) { var theObject = params[0]; var publishedUrl = params[1]; // Do something. } ).catch( function(error) { var theObject = error.target; var errorString = error.message; // Handle the error. } );
-
// Assume that the KiiObject "object" has been instantiated. // Set the expiration time of the URL. var expiresAt = new Date(2099, 12, 31); // Publish the KiiObject. object.publishBodyExpiresAt(expiresAt, { success: function(theObject, publishedUrl) { // Do something. }, failure: function(theObject, errorString) { // Handle the error. } });
The basic steps are as follows:
- Upload the file as an object body.
- Publish the file with the
publishBodyExpiresAt()
method.
Note that a user needs to be permitted the KiiACLObjectActionRead
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.