Skip to main content

Frontend Integration Active Parameter Mode

Integration Diagram

Integration Diagram

  1. Filez Document Platform and the business system need to agree on a secret to calculate the HMAC of the request URL
  2. When the business system frontend needs to call online editing/preview services, it requests the business system's server. The business system's server generates the online editing/preview URL based on the secret. The URL format is as follows:
http(s)://${zOffice_domain}/docs/app/driver-callback?repoId=${repoId}&docId=${docId}&action=edit&userinfo=${userInfo}&meta=${meta}&downloadUrl=${downloadUrl}&uploadUrl=${uploadUrl}&params=${params}&ts=${ts}&HMAC=${hmac}

See Request Parameters for all request parameters.

  1. After the Filez Document Platform server receives the request, it first verifies whether the request is correct based on the HMAC value to ensure that related parameters are not tampered with.
  2. Verify whether the request has expired based on ts (timestamp) to ensure that online editing/preview requests are not arbitrarily propagated. By default, an online editing/preview request URL address is valid for 10 seconds. The business system and Filez Document Platform need to have synchronized time.
  3. After obtaining related information from the userinfo and meta parameters, download the file from the location specified by downloadUrl.

Active Parameter Mode

Request Address:

GET http(s)://${zOffice-server-IP}:${zOffice-server-port}/docs/app/driver-callback

Request Parameter Definitions:

Parameter NameRequiredDescription
repoIdYesUnique identifier ID of the third-party service in zOffice, defined by the third-party service itself, and needs to be set in the management console at the same time.
docIdYesUnique ID of the document in the third-party system
actionNoIdentifies the behavior of opening the document, value can be edit or view, default is view
userinfoYesIdentifies the user information performing the operation, a base64-encoded JSON string. base64(JSON.stringify(userinfoObj)). Must be encoded with encodeURIComponent before concatenating to the URL
metaYesIdentifies the metadata of the current document, a base64-encoded JSON string. base64(JSON.stringify(metaObj)). Must be encoded with encodeURIComponent before concatenating to the URL
downloadUrlYesAddress for downloading the file stream, the file can be downloaded through this URL. The corresponding URL address cannot use encodeURIComponent encoding, please do not include request parameters, request parameters that need to be passed should be passed through params.
The host of downloadUrl must be consistent with the interface address prefix configured for this application in the management console. host includes hostname and port. If the host in downloadUrl does not include a port, the related configuration should not include a port either, even if it's the default port
uploadUrlNoFile upload address. Can be ignored when previewing documents, needs to be passed when editing documents. The corresponding URL address cannot use encodeURIComponent encoding, please do not include request parameters, request parameters that need to be passed should be passed through params.
paramsNoInformation that needs to be passed back, format key=value;key2=value2.
If the third-party system has permission verification when requesting downloadUrl and uploadUrl, please be sure to pass related identity information in params, otherwise the request will fail.
See params description below for details
tsYesTimestamp when the URL was generated, precision in milliseconds
HMACYesSalted hash value of the request URL, used to verify whether the request address has been tampered with

Example

http://luoshuhost:8001/docs/app/driver-callback?  
repoId=thirdpart-rest&
docId=demo-docx-123&
action=edit&
userinfo=eyJpZCI6ImxpY2h1biIsImRpc3BsYXlfbmFtZSI6Iueri%2BaYpSIsImVtYWlsIjoibGljaHVuQGxlbm92b2Nsb3VkLmNvbSJ9Cg%3D%3D&
meta=eyJjcmVhdGVkX2J5Ijp7ImlkIjoibGljaHVuIiwibmFtZSI6ImxpY2h1biIsImVtYWlsIjoibGljaHVuQGxlbm92b2Nsb3VkLmNvbSJ9fQ%3D%3D&
downloadUrl=http://thirdparty-file-server/context/content&
params=3rd-party-token=xxx;id=demo-docx-123;x-webhook-header=xxx&
ts=1685673093648&
HMAC=8b48d4833bd2e22203eb890c91a6fe08df6056bf3bda126ab31e5a9d9c04aad5
uploadUrl Notes

The Document Platform server uses HTTP POST to upload files through formData. Content type is multipart/form-data.

ParameterRequiredLocationDescriptionType
Content-TypeYesHeaderFixed as multipart/form-datastring
fileYesBody(form data)The file itself, contains two attributes: filename (fixed as content, please ignore. Currently, file names will not be modified through this API), contentType (the file's mimeType, e.g., 'application/octet-stream')multipartfile

After successful upload, the latest file modification time needs to be returned.

For example:

{
"modified_at": "2020-03-25T02:57:38.000Z" // Required, this time should be the latest save time of this file in the business system, and this save is brought about by this API.
}

userinfo Description

Properties

Field NameRequiredDescription
idYesUser ID
display_nameYesUser nickname
emailYesUser email, can be the same as id
photo_urlNoUser avatar

JSON Representation

{  
"id": "301", // User ID
"display_name": "docstest02", // User nickname
"email": "docstest02@lenovocloud.com", // User email
"photo_url": "https://avatar.thirdparty.com/testOrg/people/301.png", // User avatar
}

meta Description

meta supports passing in the following information, other information will be filtered. The following information can be selected to transmit only part of the information.

Properties

Field NameRequiredTypeExample ValueDescription
idYesString577Unique file ID, must be consistent with docId in the request URL
nameYesStringpreview-center.docxFile name including extension
modified_atYesString2023-08-17T13:57:38.000ZModification time, format needs to be consistent with the example on the left. See detailed description below
created_by.idYesString301Document creator ID
created_by.nameYesStringdocstest02Document creator name
permissions.writeYesBooleantrueWhether has edit permission
permissions.readYesBooleantrueWhether has read permission
permissions.downloadNoBooleantrueWhether the file can be downloaded. If the file cannot be downloaded, the file content cannot be copied to places other than the current file. Default value is false
permissions.printNoBooleantrueWhether the file can be printed. Default value is false
roleNoStringcommenterThis value can be "contributor", "commenter", "auditor". Default value is none
waterMark.line1NoStringFilez zOffice docstest02Watermark first line, default is empty
waterMark.line2NoStringlast modified userWatermark second line, default is empty
waterMark.line3NoStringproduct infoWatermark third line, default is empty
waterMark.line4NoStringmore infoWatermark fourth line, default is empty
waterMark.withDataNoBooleantrueWhether watermark includes date, default true
waterMark.fontcolorNoString#cececeWatermark color, default gray
waterMark.transparentNoNumber70Transparency. The smaller the value, the more obvious the transparent effect, default 70, type is number
waterMark.rotationNoNumber315Rotation angle, range 0-360, e.g., left tilt=315, right tilt=45, horizontal=0, type is number
waterMark.fontsizeNoString16Watermark font size, default 16
waterMark.fontNoStringSimHeiWatermark font, default SimHei
waterMark.spacingNoNumber50Line spacing, default 50, type is number
owner.idNoString301Document owner ID
owner.nameNoStringdocstest02Document owner name
extension.previewWithTrackChangeNoBooleanfalsetrue means revisions are automatically displayed during preview. false or not providing this field means revisions are not displayed during preview. Only for text documents
extension.trackChangeForceOnNoBooleanfalsetrue means revisions are automatically turned on during editing and cannot be turned off. false or not providing this field means revisions are not forced on during editing. Only for text documents.

JSON Representation

{  
"id": "577",
"name": "preview-center.docx",
"modified_at": "2023-08-17T13:57:38.000Z",
"created_by": {
"id": "301",
"name": "docstest02"
},
"permissions": {
"write": true, // Controls whether the document can be edited
"read": true, // Controls whether the document can be previewed
},
"role": "commenter", // Optional, indicates the current user's role in the zoffice editor for the current document (only for text documents). This value can be "contributor", "commenter", "auditor".
"extension": {
"previewWithTrackChange": false, // true means revisions are automatically displayed during preview. false or not providing this field means revisions are not displayed during preview. Only for text documents.
"trackChangeForceOn": false, // true means revisions are automatically turned on during editing and cannot be turned off. false or not providing this field means revisions are not forced on during editing. Only for text documents.
},
"waterMark": { // Document watermark related
"line1": "李明liming@lenovo.com", // For example, file last updater information
"line2": "张三hangshan@lenovo.com", // For example: file editor/previewer information
"line3": "", // For example: other custom text
"line4": "", // For example: other custom text
"withDate": true, // Whether to include date after each line of text
"fontcolor": "#fD4147", // RGB value,
"transparent": 30, // 0-100, transparency. The smaller the value, the more obvious the transparent effect.
"rotation": 315, // Rotation angle 0-360, left tilt=315, right tilt=45, horizontal=0
"fontsize": "72",
"font": "SimHei"
}
}

modified_at Implementation Must Pay Attention Please refer to: Cache Notes

params

Information passed in params will be passed back in header, cookie, and queryParams when calling third-party interfaces.

For example, when params=x-param-1=aaa;x-param-2=bbb, and the third-party interface is /v2/context/docId/content, the actual request received by the third party is as follows:

Request Address: /v2/context/docId/content?x-param-1=aaa&x-param-2=bbb

Request Headers:

x-param-1: aaa
x-param-2: bbb

Cookie: x-param-1=aaa;x-param-2=bbb

Note: Parameters that need to be passed back in the header must start with x- (can be modified through special configuration headerPrefix default value)