简体   繁体   English

使用Chrome API将文件保存到USB

[英]Save a file to a USB with Chrome API

I have a Chrome app with "usb" permission and I want to create a file "notes.txt" in USB mass storage. 我有一个具有"usb"权限的Chrome应用,我想在USB大容量存储中创建文件“ notes.txt”。 When he finished and press "save to USB" button. 完成后,按“保存到USB”按钮。

I tried to use chrome.usb.bulkTransfer, but it just ends with 我尝试使用chrome.usb.bulkTransfer,但其结尾为

Unchecked runtime.lastError while running usb.bulkTransfer: Transfer failed.

Is possible to save a file to a USB mass storage with Chrome API, without the direct input from user? 无需用户直接输入,是否可以使用Chrome API将文件保存到USB大容量存储中?

Regarding saving a file to a USB mass storage without the direct input from user, try using chrome.usb.controlTransfer(connectionHandle, transferInfo, transferCallback) which is generally used to send or receive configurations or command parameters to a USB device. 关于在没有用户直接输入的情况下将文件保存到USB大容量存储,请尝试使用chrome.usb.controlTransfer(connectionHandle, transferInfo, transferCallback) ,该方法通常用于向USB设备发送或接收配置或命令参数。 The controlTransfer method always sends to/reads from endpoint 0, and no claimInterface is required. controlTransfer方法始终发送到端点0或从端点0读取数据,并且不需要ClaimInterface。

And since requestAccess is now deprecated, operation is now implicitly performed as part of openDevice and this function will return true on all platforms. 而且由于现在不赞成使用requestAccess ,因此现在作为openDevice一部分隐式执行操作,并且该函数在所有平台上都将返回true。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM