全部產品
Search
文件中心

Drive and Photo Service:喚起案頭用戶端

更新時間:Jul 06, 2024

說明

本篇主要介紹如何通過URLScheme 喚醒案頭用戶端,並做指定的動作。

1 URLScheme

BasicUI 案頭用戶端 URLScheme 的協議格式為: "pds"+domainID

假設您的DomainID為 hz65, 那麼URLScheme為 : pdshz65:

開啟URL舉例:

window.open("pdshz65:open?opt=%7B%22seq_id%22%3A%22x3hug4qu1xn%22%2C%22pathname%22%3A%22%2Findex%22%7D")

2 URL參數詳解

<protocol>:<action>?opt=[opt]

欄位

描述

protocol

協議名稱,’pds’+domainID 組成。

action

url 的 pathname , 一般為動詞, 目前支援:opendownload

opt

opt 為json 字串 encodeURI 後的字串,encodeURIComponent(JSON.stringify(opt))

2.1 開啟指定URL

opt 參數詳解:

欄位

描述

seq_id

序列id,在一次會話中(開啟案頭端到關閉案頭端)不可重複。

pathname

喚醒後,要跳轉到的 pathname。

舉例:

let domainId='hz65'
let action='open'
let opt ={
  "seq_id": Math.random().toString(36).substring(2),
  "pathname":"/drive"
}
let url = `pds${domainId}:${action}?opt=${encodeURIComponent(JSON.stringify(opt))}`
window.open(url)

2.2 下載指定的檔案

opt 參數詳解:

欄位

描述

seq_id

序列id,在一次會話中(開啟案頭端到關閉案頭端)不可重複。

pathname

喚醒後,要跳轉到的 pathname

loc_type

所在位置類型。取值為:drive 或者 share

loc_id

loc_typedrive時,取值為drive_id, 為share時,取值為share_id

file_keys

要下載的檔案 file_id(標準模式)或者 file_path(託管模式)的數組,格式如:["file_id1","file_id2"] 。

舉例:

let domainId='hz65'
let action='download'
let opt ={
  "seq_id": Math.random().toString(36).substring(2),
  "loc_type": "drive",
  "loc_id": "1",
  "pathname":"/drive/folders/5e9d2e02570e5a973cd64b648cbf97ac2ebb26dc",
  "file_keys":["5faebd028e8365fef08b4a019308765631e179e0"]
}
let url = `pds${domainId}:${action}?opt=${encodeURIComponent(JSON.stringify(opt))}`
window.open(url)