camera.uploadFile
برنامه این دستور را به دوربین می دهد تا بارگذاری تصویر یا ویدیو را مستقیماً از دوربین به سرور آغاز کند. دوربین باید از پارامترهای موجود برای تشکیل یک درخواست HTTP POST استفاده کند. فایلی که باید آپلود شود توسط fileUrl
مشخص شده است و باید با مجوز صحیح مشخص شده توسط accessToken
در uploadUrl
آپلود شود. این دستور در سطح 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." } } |
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2024-11-08 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2024-11-08 بهوقت ساعت هماهنگ جهانی."],[[["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"]]