Packagecom.adobe.share.api
Classpublic class ShareAPI
InheritanceShareAPI Inheritance flash.events.EventDispatcher

ShareAPI is the helper class for accessing the Adobe Share API. It provides much of the client-side functionality for applications; for example, logging in and out, uploading files, sharing files, and so on. While many of these functions call functions in the ShareAPINode and ShareAPIUser classes, most of the work is done here. These functions build the requests with the appropriate XML payload and parse the responses.



Public Methods
 MethodDefined by
  
ShareAPI(apikey:String, secret:String)
Share API constructor.
ShareAPI
  
addFolder(user:ShareAPIUser, folderName:String, folderDescription:String, parentId:String):ShareAPIToken
Adds a new folder to Share by building a request with an XML payload containing the requisite details.
ShareAPI
  
deleteNode(user:ShareAPIUser, nodeId:String):ShareAPIToken
Deletes a file or folder node node by constructing an HTTP request using the DELETE method and the requisite node ID.
ShareAPI
  
downloadFile(user:ShareAPIUser, nodeId:String):ShareAPIToken
downloadFile constructs an url request containing the node URL, session information, and user details.
ShareAPI
  
Gets the details of the requested node from the Share response.
ShareAPI
  
getNodes(user:ShareAPIUser, nodeId:String = null):ShareAPIToken
Gets a list of nodes (files and folders) in a user's account.
ShareAPI
  
getThumbnail(user:ShareAPIUser, nodeId:String):ShareAPIToken
Returns the thumbnail of a document as a stream.
ShareAPI
  
login constructs a log in request so the user can login to Share.
ShareAPI
  
logout logs a user out by ending the current session.
ShareAPI
  
shareFile(user:ShareAPIUser, nodeId:String, users:Array, emailMessage:String, level:int):ShareAPIToken
Shares an existing file or node with one or more specified users.
ShareAPI
  
updateShare(user:ShareAPIUser, nodeId:String, usersToAdd:Array, usersToRemove:Array, emailMessage:String):ShareAPIToken
Updates a shared file by adding and removing users with permission to access the file.
ShareAPI
  
uploadFile(user:ShareAPIUser, file:FileReference, nodeId:String, name:String, description:String, renditions:Boolean, createpdf:Boolean = false):void
Uploads and adds a file to Share by building a request with an XML payload containing the requisite details.
ShareAPI
Constructor detail
ShareAPI()constructor
public function ShareAPI(apikey:String, secret:String)

Share API constructor. Note that the developer must have registered with Share and will need to have an API key and secret to continue.

Parameters
apikey:String — The API key registered for this application
 
secret:String — The shared secret assigned to this API key
Method detail
addFolder()method
public function addFolder(user:ShareAPIUser, folderName:String, folderDescription:String, parentId:String):ShareAPIToken

Adds a new folder to Share by building a request with an XML payload containing the requisite details.

Parameters
user:ShareAPIUser — The user performing that is executing this action
 
folderName:String — The name of the new folder
 
folderDescription:String — The new folder's description.
 
parentId:String — The target parent node under which to add this folder. If set to null, the folder is added to the root node.

Returns
ShareAPIToken
deleteNode()method 
public function deleteNode(user:ShareAPIUser, nodeId:String):ShareAPIToken

Deletes a file or folder node node by constructing an HTTP request using the DELETE method and the requisite node ID.

Parameters
user:ShareAPIUser — Execute method on behalf of this user
 
nodeId:String — Node to delete

Returns
ShareAPIToken
downloadFile()method 
public function downloadFile(user:ShareAPIUser, nodeId:String):ShareAPIToken

downloadFile constructs an url request containing the node URL, session information, and user details. Note that sig is the MD5 digest of the string formed by concatenating data with the shared secret returned by an authorization token request.

Parameters
user:ShareAPIUser — The user who is downloading the file
 
nodeId:String — The nodeId of the file to download

Returns
ShareAPIToken
getNodeDetails()method 
public function getNodeDetails(user:ShareAPIUser, nodeId:String):ShareAPIToken

Gets the details of the requested node from the Share response.

Parameters
user:ShareAPIUser — Execute method on behalf of this user
 
nodeId:String — Node to get the details about

Returns
ShareAPIToken
getNodes()method 
public function getNodes(user:ShareAPIUser, nodeId:String = null):ShareAPIToken

Gets a list of nodes (files and folders) in a user's account. Share returns a substantial amount of detail about each node, and getNodes calls functions in ShareAPINode to parse the data.

Parameters
user:ShareAPIUser — Execute method on behalf of this user
 
nodeId:String (default = null) — List nodes that are children of this node. If this is null, use user's root node as parent.

Returns
ShareAPIToken
getThumbnail()method 
public function getThumbnail(user:ShareAPIUser, nodeId:String):ShareAPIToken

Returns the thumbnail of a document as a stream. Note that folders do not have thumbnails, and not all files will have thumbnails.

Parameters
user:ShareAPIUser — Execute method on behalf of this user
 
nodeId:String — Node to get thumbnail of

Returns
ShareAPIToken
login()method 
public function login(user:ShareAPIUser):ShareAPIToken

login constructs a log in request so the user can login to Share. If successful, user object will have its session ID and secret attributes set.

Parameters
user:ShareAPIUser — The user to log in

Returns
ShareAPIToken
logout()method 
public function logout(user:ShareAPIUser):ShareAPIToken

logout logs a user out by ending the current session. In this example, the session is ended by constructing an HTTP request using the DELETE method and the current session ID.

Parameters
user:ShareAPIUser — The user to log out

Returns
ShareAPIToken
shareFile()method 
public function shareFile(user:ShareAPIUser, nodeId:String, users:Array, emailMessage:String, level:int):ShareAPIToken

Shares an existing file or node with one or more specified users. The share level is set by setting level to 0, 1, or 2. For example, this code could take in a value set from a client's user interface, builds an XML payload containing a list of specified users (if any), a message (which can be null), and the share level. It then constructs an HTTP request using the PUT method and the path to the requisite file.

Parameters
user:ShareAPIUser — Execute method on behalf of this user
 
nodeId:String — The file node to share
 
users:Array — The list of users to share with
 
emailMessage:String — Optional message to include in email
 
level:int — 0 for private, 1 for enumerated users, 2 for public access

Returns
ShareAPIToken
updateShare()method 
public function updateShare(user:ShareAPIUser, nodeId:String, usersToAdd:Array, usersToRemove:Array, emailMessage:String):ShareAPIToken

Updates a shared file by adding and removing users with permission to access the file. It builds an XML payload containing a list of specified users to add and remove and then constructs an HTTP request using the PUT method and the path to the requisite file.

Parameters
user:ShareAPIUser — Execute method on behalf of this user
 
nodeId:String — File node to the share
 
usersToAdd:Array — Add these users to the share
 
usersToRemove:Array — Remove these users from the share
 
emailMessage:String — Optional message to include in the email

Returns
ShareAPIToken
uploadFile()method 
public function uploadFile(user:ShareAPIUser, file:FileReference, nodeId:String, name:String, description:String, renditions:Boolean, createpdf:Boolean = false):void

Uploads and adds a file to Share by building a request with an XML payload containing the requisite details. Note that sig is the MD5 digest of the string formed by concatenating data with the shared secret returned by an authorization token request.

Parameters
user:ShareAPIUser — Execute method on behalf of this user
 
file:FileReference — File to upload
 
nodeId:String — Upload file using this name
 
name:String — Description of file. Set to null for none.
 
description:String — Upload file under this folder node. If null, upload to root node.
 
renditions:Boolean — Set to true to generate renditions (thumbnail, flash preview) for this document
 
createpdf:Boolean (default = false)