kamera.uploadFile
Aplikasi memberikan perintah ini ke kamera untuk memulai upload gambar atau
video langsung dari kamera ke server. Kamera harus menggunakan
parameter untuk membentuk permintaan POST HTTP. File yang akan diupload ditentukan oleh
fileUrl
dan file harus diupload ke uploadUrl
dengan
otorisasi yang ditetapkan oleh accessToken
. Perintah ini ditambahkan di level API
2.1 dan relevan dengan
Upload Langsung
Kita dapat melakukan ini dari baris perintah komputer sebagai:
curl -X post -H "Authorization: Bearer accessToken" -T fileUrl uploadUrl
Parameter
fileUrl:
URL file yang akan diupload ke server.
uploadUrl:
String yang mewakili tempat mengupload file.
accessToken:
Token yang mencakup informasi autentikasi untuk
upload. Data ini diperoleh oleh aplikasi dan dikirim ke kamera.
Hasil
- Perintah ini tidak menampilkan hasil.
Error
missingParameter:
Beberapa parameter, misalnya, fileUrl
tidak ada.
invalidParameterName:
Satu atau beberapa nama parameter input
tidak dikenal.
invalidParameterValue:
Nama parameter input dikenali
tetapi satu atau beberapa nilai yang diteruskan tidak valid. Misalnya, file yang ditentukan oleh
fileUrl
tidak ada.
uploadError:
Kamera gagal diupload.
I/O Perintah |
|
Input Perintah |
{ "parameters": { "fileUrl": "URL of the file.", "uploadUrl": "A string representing where to upload the file.", "accessToken": "A token containing the authentication information." } } |
Output Perintah |
none |
Output Perintah (Error) |
{ "error": { "code": "uploadError", "message": "Camera failed to upload the file." } } |
Kecuali dinyatakan lain, konten di halaman ini dilisensikan berdasarkan Lisensi Creative Commons Attribution 4.0, sedangkan contoh kode dilisensikan berdasarkan Lisensi Apache 2.0. Untuk mengetahui informasi selengkapnya, lihat Kebijakan Situs Google Developers. Java adalah merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2024-08-21 UTC.
[null,null,["Terakhir diperbarui pada 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"]]