camera.uploadFile
Ứng dụng sẽ đưa ra lệnh này cho máy ảnh để bắt đầu tải hình ảnh lên hoặc
trực tiếp từ máy ảnh vào máy chủ. Camera nên sử dụng
để tạo yêu cầu POST qua HTTP. Tệp sẽ được tải lên được chỉ định bởi
fileUrl
và tệp này phải được tải lên uploadUrl
bằng mã
uỷ quyền do accessToken
chỉ định. Lệnh này đã được thêm vào cấp độ API
2.1 và có liên quan đến
Tải lên trực tiếp
Người dùng có thể thực hiện việc này từ dòng lệnh trên máy tính như sau:
curl -X post -H "Authorization: Bearer accessToken" -T fileUrl uploadUrl
Tham số
fileUrl:
URL của tệp sẽ được tải lên máy chủ.
uploadUrl:
Một chuỗi đại diện cho vị trí tải tệp lên.
accessToken:
Mã thông báo bao gồm thông tin xác thực cho
tải lên. Ứng dụng lấy mẫu này và gửi đến máy ảnh.
Kết quả
- Lệnh này không trả về kết quả nào.
Lỗi
missingParameter:
Một số tham số bị thiếu, ví dụ: fileUrl
.
invalidParameterName:
Một hoặc nhiều tên tham số đầu vào là
không nhận dạng được.
invalidParameterValue:
Tên tham số đầu vào được nhận dạng
nhưng một hoặc nhiều giá trị đã chuyển không hợp lệ. Ví dụ: tệp được chỉ định bởi
fileUrl
không tồn tại.
- Không tải được
uploadError:
camera lên.
Lệnh I/O |
|
Nhập lệnh |
{ "parameters": { "fileUrl": "URL of the file.", "uploadUrl": "A string representing where to upload the file.", "accessToken": "A token containing the authentication information." } } |
Kết quả lệnh |
none |
Ra lệnh (Lỗi) |
{ "error": { "code": "uploadError", "message": "Camera failed to upload the file." } } |
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2024-08-21 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2024-08-21 UTC."],[[["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"]]