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:
系統會辨識輸入參數名稱
但一或多個傳送的值無效。例如,由 Google 代管的檔案
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." } } |
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2024-08-21 (世界標準時間)。
[null,null,["上次更新時間:2024-08-21 (世界標準時間)。"],[[["This command, available in API level 2.1 and later, allows apps to instruct the camera to directly upload images or videos to a server."],["The camera uses provided parameters (`fileUrl`, `uploadUrl`, `accessToken`) to form and send an HTTP POST request to the specified server."],["Direct Upload requires obtaining an access token and providing the file's URL and the server's upload URL within the command parameters."],["While the command itself returns no result, potential errors during the upload process can be indicated by specific error codes like `uploadError` or `invalidParameterValue`."]]],["The app directs the camera to upload a file to a server using an HTTP POST request. Key parameters include `fileUrl` (the file's location), `uploadUrl` (the destination), and `accessToken` (authorization token). The camera utilizes these parameters to perform the upload. No direct result is returned upon command execution, but error messages such as `missingParameter`, `invalidParameterValue` or `uploadError` will be returned if the command is not correctly executed. This feature was introduced in API level 2.1.\n"]]