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." } } |
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-08-21。
[null,null,["最后更新时间 (UTC):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"]]