Custom Right-Click Menu

Updated: 2017-05-15

Overview

This feature allows administrators to add custom right-click menu options for files within the enterprise library. When users select a file and click on the custom menu option, it can trigger an API call or open a web page, passing the selected file's information as parameters to the specified interface or web page.

Configuration

Administrators can configure this in the Enterprise Management Console under Custom Right-Click Menu. The settings are as follows:

Setting Description
Menu Name The name of the menu item as seen by users in the right-click menu.
Menu English Name The name of the menu item in English. If not set, the Chinese name is shown by default.
Order The display order of the custom menu items.
Call Type The action type, either API Call or Popup Window.

API Call

If the action type is API Call, clicking the menu item will automatically trigger an API call. You need to specify:

Setting Description
API URL The URL of the API to be called.
Request Method The HTTP method, either POST or GET.
Return Feedback Whether to show the result of the API call to the user.

Popup Window

If the action type is Popup Window, clicking the menu item will open a web page. You need to specify:

Setting Description
Page URL The URL of the web page to be opened in the popup.

Usage Flow

  1. The administrator sets up the Custom Right-Click Menu in the management console.
  2. Users select a file in the library and right-click to choose the custom menu item.
  3. If the menu action type is API Call, the server will call the specified API with the parameters.
  4. If the menu action type is Popup Window, the client will open the specified web page in a new window.

API Call Parameters

When users click the custom menu, the following parameters are sent to the API or web page URL:

Parameter Name Description
org_id The ID of the library being accessed.
mount_id The space ID of the library.
hash The unique identifier of the file.
fullpath The full path of the file.
filehash The unique content identifier of the file. (Not sent if a folder.)
filesize The size of the file. (Not sent if a folder.)
dateline The current Unix timestamp, in seconds.
sign The signature for security validation.

Handling the Request on the Receiver's Side

  1. Receive the parameters.
  2. Verify the signature (refer to API rules for signature algorithm; this step can be ignored if security validation is not needed).
  3. Optionally, use the Enterprise Development API to obtain library authorization and file information.
  4. Process the request.
  5. Return the result of the processing.

API Call Result Format

The result returned from the API call should be in JSON format. A successful call returns HTTP status 200, while a failure returns an HTTP status >= 400. The JSON structure is:

{
    "code": result_code,
    "message": "Result message displayed to the user"
}

If the processing time is lengthy, consider using a queuing system to avoid request timeouts.