[Up]: Storage API : Shared Folder manage

Shared Folder Manage

Script path: /storage/bin/api/share_manage.cgi

Description:   Creates a new shared folder. Also view, update, and dismisses an existing shared folder.

INPUT (via GET or POST)

   sid => the authenticated session id  (must be valid)

act => view | create | update | dismiss

view (Show the detailed info of a particular shared folder. ONLY the owner of the shared folder OR the user
shared to can access this info.)

INPUT
share_id => an existing shared folder id

OUTPUT
details of the shared item

Possible errors:
shard_id is not valid, or user is not owner or the shared to user.


create (Create a new shared folder. This can only be done by the owner of the folder.)

INPUT
path => existing storage folder to share out e.g. /Private/myfolder/toshare
NOTE: ONLY Private and Private HomePage folders or subfolders can be shared.
Company Share and Network Share folders cannot be further shared.

share_to => email_id (name@domain) of the person to share to.
share_name => optional basename to share as. If left blank, the basename of the path will be used.
read_access => yes | no (default yes)
write_access => yes | no (default no)

notify_share_to => yes | no (default no) -- whether to send email notification to share_to user or not

OUTPUT
share_id
share_name (the actual share name applied, which maybe renamed for uniqueness.)

Possible errors:
Path does not exist.



update (Update share name and access privilege. This action can only be done by the owner of the folder.)

INPUT
share_id => <alpha-numeric-string>
share_name => new sharename to update. (If left blank, it will not be changed.)
read_access => yes | no (New rights. If left blank, it will not be changed.)
write_access => yes | no (New rights. If left blank, it will not be changed.)

OUTPUT
Result of the update

Possible errors:
share_id does not exist
user is not owner of shared folder


dismiss (Dismisses a shared folder. This action can be done by the owner of the folder OR the shared_to user.)

INPUT
share_id => <alpha-numeric-string>

OUTPUT
Result of the dismissal

Possible errors:
share_id does not exist.
user is NOT the person the folder was shared to.


ofmt => output format defaults to JSON format with minimal white spaces.
ofmt = jsonp means to produce JSON format in pretty printed way (easier to read)



OUTPUT (content-type: text/plain)


    JSON output object:

{
"status" : true | false,
// true only if the API completes successfully
// false if otherwise

"errmsg" : error message, if status is false,
"errcode" : internal error code (alphanumeric) only if in case of error,

"share_id" : <alpha-numeric-string> (For the case of share creation only)
"share_name" : <alpha-numeric-string> (For the case of share creation only)

"share_item" : { JSON object with details of the shared item (see below). } (For the case of view only.)

}

JSON object for "share_item"

"share_item" : {

"share_id" : the shared item ID (alphanumeric)

"share_to_user_is_valid" : true | false -- whether the share-to user info is valid or not
"share_to_email_id" : the share-to user's id (or internal id)
"share_to_real_email" : the share-to user's email (user email address)
"share_to_fullname" : the share-to user's fullname, if any

"share_from_user_is_valid" : true | false -- whether the share-from user info is valid or not
"share_from_email_id" : the shared item's user's id (internal id)
"share_from_real_email" : the shared item's user's email (user email address)
"share_from_fullname" : the shared item's user's fullame, if any

"shared_item_is_valid" : true | false -- whether the folder is still available from owner
"share_path" : the storage path to the item (for now is only folder)
"share_path_basename" : the item's basename (the last component of spath)

"share_name" : shared as this name (The shared to user will see this, set by owner)

"read_access" : "yes" | "no"
"write_access" : "yes" | "no"

}

Appropriate HTTP header status codes are also returned e.g. 200 OK, 401 Invalid user profile, etc.



Examples:

After a successful share creation:
{
"status" : true,
"errmsg" : ""
"share_id" : "eZt8x3kHdKFNvyHSeY2lNBTnuwipm9FB3eJgCvJr",
"share_name" : "Project WorldX",
}

After a request to view a particular share_id:
{
"share_item" : {
"read_access" : "yes",
"share_path_basename" : "公司分享",
"share_to_user_is_valid" : true,
"shared_item_is_valid" : true,
"write_access" : "no",
"share_from_email_id" : "sschan@noc.afteroffice.com",
"share_id" : "5fbO0Kb6aTvcJ3aU3D3s56w35H3ppwrpWA5TVyhw",
"share_to_fullname" : "fui公 2",
"share_from_fullname" : "Sian Sit Chan",
"share_name" : "公司分享",
"share_path" : "/Private/testfolder/公司分享",
"share_to_email_id" : "fui@noc.afteroffice.com",
"share_to_real_email" : "fui@noc.afteroffice.com",
"share_from_user_is_valid" : true,
"share_from_real_email" : "sschan@noc.afteroffice.com"
},
"status" : true,
"errmsg" : ""
}

After another request to view a particular share_id:
{
"share_item" : {
"read_access" : "no",
"share_path_basename" : "testfolder",
"share_to_user_is_valid" : false,
"shared_item_is_valid" : true,
"write_access" : "yes",
"share_from_email_id" : "sschan@noc.afteroffice.com",
"share_id" : "QRJY3MU4DavZ7XQb5WRmo6INrZ7YItKPOLxOkPnc",
"share_to_fullname" : null,
"share_from_fullname" : "S S Chan",
"share_name" : "日本の騎手",
"share_path" : "/Private/testfolder",
"share_to_email_id" : "nobody@noc.afteroffice.com",
"share_to_real_email" : "nobody@noc.afteroffice.com",
"share_from_user_is_valid" : true,
"share_from_real_email" : "sschan@noc.afteroffice.com"
},
"status" : true,
"errmsg" : ""
}