camera.uploadFile

應用程式會向相機發出這個指令,以便將圖片或影片直接從相機上傳到伺服器。相機應使用內含的參數來建立 HTTP POST 要求。要上傳的檔案由 fileUrl 指定,且必須上傳至 uploadUrl,獲得 accessToken 指定的正確授權。這個指令在 API 級別 2.1 版中新增,與直接上傳相關

您可以透過電腦指令列執行這項作業,例如:

curl -X post -H "Authorization: Bearer accessToken" -T fileUrl uploadUrl

參數

  • fileUrl: 要上傳到伺服器的檔案網址。
  • uploadUrl: 字串,代表上傳檔案的位置。
  • accessToken: 包含上傳驗證資訊的權杖。由應用程式取得並傳送至相機。

結果

  • 這個指令不會傳回任何結果。

錯誤

  • missingParameter: 缺少部分參數,例如 fileUrl
  • invalidParameterName: 無法辨識一或多個輸入參數名稱。
  • invalidParameterValue: 可識別輸入參數名稱,但一或多個傳遞值無效。例如,fileUrl 指定的檔案不存在。
  • uploadError: 無法上傳相機。
指令 I/O
指令輸入
{
"parameters": {
"fileUrl": "URL of the file.",
"uploadUrl": "A string representing where to upload the file.",
"accessToken": "A token containing the authentication information."
}
}
指令輸出
none
指令輸出 (錯誤)
{
"error": {
"code": "uploadError",
"message": "Camera failed to upload the file."
}
}