ShareAPI.js

/**
 * @classdesc
 * Provides the APIs for managing the logged-in user's shared files. Instances of this class should be obtained using 
 * {@link system#shares|system.shares}.
 * @class
 * @hideconstructor
*/
ShareAPI = function () {
	/**
	* Add a file to the share index without sharing it. The file must be uploaded to the 
	* userShareDirectoryPath as returned by {@link ShareAPI#getShareDirectoryPaths|getShareDirectoryPaths()}.
	* 
	* @method
	* @param {String} fileName Name of the file to be stored.
	* @param {Number} expectedFileSize Size of the file to be stored.
	*/
	this.storeFile = function (fileName, expectedFileSize) { }

	/**
	* Add a file to the share index as specified by the {@link ShareConfig|config} argument. The file must be uploaded to the 
	* userShareDirectoryPath as returned by {@link ShareAPI#getShareDirectoryPaths|getShareDirectoryPaths()}.
	* 
	* @method
	* @param {String} fileName Name of the file to be shared.
	* @param {ShareConfig} config Instructions for how the file is to be shared.
	* @return {String} Path of the share within the virtual file-system. This, appended to the hostname, is the sharing URL.
	*/
	this.shareFile = function (fileName, config) { }

	/**
	* Change the sharing details of a previously shared file.
	* 
	* @method
	* @param {String} fileName Name of the file.
	* @param {Boolean} enableLinkSharing Should the file be shared?
	* @param {Date} expiryDateUtc (Optional) expiry date of the share (UTC).
	* @param {Boolean} setPassword Is the file being shared with a password?
	* @param {String} password (Optional) password of the share.
	* @return {ShareInfo} 
	*/
	this.changeSharing = function (fileName, enableLinkSharing, expiryDateUtc, setPassword, password) { }

	/**
	* Returns an Array containing information about each share.
	* 
	* @method
	* @return {Array.<ShareInfo>} 
	*/
	this.list = function () { }

	/**
	* Removes a file from the sharing index. Note that this DOES NOT DELETE THE FILE itself.
	* 
	* @method
	* @param {String} fileName Name of the file to remove from the index.
	*/
	this.removeFile = function (fileName) { }

	/**
	* Returns directory paths related to file-sharing.
	* 
	* @method
	* @return {ShareDirectoryPaths} 
	*/
	this.getShareDirectoryPaths = function () { }

	/**
	* Returns sharing information of the file at the specified path in the virtual file-system. 
	* 
	* @method
	* @param {String} fullSharePath Absolute path of a file in the virtual file-system. Note that this is not just share name of a shared file.
	* @return {ShareInfo} 
	*/
	this.getShareInfo = function (fullSharePath) { }

}

/**
 * Specifies how the file is to be shared, as well as its size.
 * 
 * @typedef {Object} ShareConfig
 * @property {Date} expiryDateUTC Expiry date of the share (UTC).
 * @property {Number} expectedFileSize Size of the file to be shared.
 * @property {String} password (Optional) password of the share. If no password is provided then the file is shared without a password.
 */

/**
 * Contains all information about a shared file.
 * 
 * @typedef {Object} ShareInfo
 * @property {String} fileName Name of the file.
 * @property {String} sharePath Path of the share within the virtual file-system. This, appended to the hostname, is the sharing URL.
 * @property {String} id Unique identifier of the share file (last part of the sharePath)
 * @property {Number} expectedFileSize Size of the file once it's fully uploaded.
 * @property {Number} actualFileSize Current size of the file on the server (it may be less than the expectedFileSize if it hasn't finished uploading).
 * @property {Date} expiryDateUTC Expiry date of the sharing (UTC) or null of the file is not shared.
 * @property {Date} modifiedDateUTC Time when the sharing information was last modified (note this is not the same as the modification time of the file itself).
 * @property {Date} createdDateUTC Time when the sharing information was created.
 * @property {Date} fileModifiedDateUTC Time when the file was last modified (note this is different from the modification time of the share).
 */

/**
 * Directory paths related to sharing.
 * 
 * @typedef {Object} ShareDirectoryPaths
 * @property {String} globalShareDirectoryPath The virtual file-system path of the sharing index (usually /Shares).
 * @property {String} userShareDirectoryPath The path of the user's shared files (usually /Home/UserName/Shares).
 */