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。"],[[["\u003cp\u003eThis command, available in API level 2.1 and later, allows apps to instruct the camera to directly upload images or videos to a server.\u003c/p\u003e\n"],["\u003cp\u003eThe camera uses provided parameters (\u003ccode\u003efileUrl\u003c/code\u003e, \u003ccode\u003euploadUrl\u003c/code\u003e, \u003ccode\u003eaccessToken\u003c/code\u003e) to form and send an HTTP POST request to the specified server.\u003c/p\u003e\n"],["\u003cp\u003eDirect Upload requires obtaining an access token and providing the file's URL and the server's upload URL within the command parameters.\u003c/p\u003e\n"],["\u003cp\u003eWhile the command itself returns no result, potential errors during the upload process can be indicated by specific error codes like \u003ccode\u003euploadError\u003c/code\u003e or \u003ccode\u003einvalidParameterValue\u003c/code\u003e.\u003c/p\u003e\n"]]],["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"],null,["# camera.uploadFile\n\nThe app issues this command to the camera to initiate upload of an image or\nvideo directly from the camera to a server. The camera should use the included\nparameters to form an HTTP POST request. The file to be uploaded is specified by\n`fileUrl` and it should be uploaded to `uploadUrl` with the correct\nauthorization specified by `accessToken`. **This command was added in API level\n2.1 and is relevant to\n[Direct Upload](/streetview/open-spherical-camera/guides/direct-upload)**\n\nOne could do this from a computer command line as: \n\n curl -X post -H \"Authorization: Bearer accessToken\" -T fileUrl uploadUrl\n\nParameters\n----------\n\n- `fileUrl:` The URL of the file to be uploaded to the server.\n- `uploadUrl:` A string representing where to upload the file.\n- `accessToken:` A token including the authentication information for the upload. It is obtained by the app and sent to the camera.\n\nResults\n-------\n\n- This command returns no result.\n\nErrors\n------\n\n- `missingParameter:` Some parameter, for example, `fileUrl` is missing.\n- `invalidParameterName:` One or more input parameter names are unrecognized.\n- `invalidParameterValue:` Input parameter names are recognized but one or more passed value are invalid. For example, the file specified by the `fileUrl` does not exist.\n- `uploadError:` Camera failed to upload.\n\n| Command I/O | |\n|----------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| **Command Input** | ```gdscript { \"parameters\": { \"fileUrl\": \"URL of the file.\", \"uploadUrl\": \"A string representing where to upload the file.\", \"accessToken\": \"A token containing the authentication information.\" } } ``` |\n| **Command Output** | ```text none ``` |\n| **Command Output (Error)** | ```gdscript { \"error\": { \"code\": \"uploadError\", \"message\": \"Camera failed to upload the file.\" } } ``` |"]]