简体   繁体   中英

How to access USB device in chrome?

I need a web application which is used to copy the files from usb drive. I can write a java applet to copy the files from usb drive, but chrome will not support applet any more. Could you please suggest any alternative to this? I need a web application not a chrome app.

I'd recommend using node.js , its cross platform and can access usb ports from web browser..

Usb Library: https://www.npmjs.com/package/usb

Proof : How to send data to USB device in node.js using libusb

Hope this helps

Chrome 61+ has an implementation of the WebUSB API

This would not let you issue a command to the OS/File system to, for example:

copy file://some_file_location/myfile.txt to file://USB_DRIVE/some_folder/myfile.txt

Chrome would need to read the files and write to the device directly. In other words the browser would be copying the files by reading them (see below) and then writing to the USB device. This would probably be quite slow and unfeasible for large files.

Your options to read local files are:

  • To run chrome with the --allow-file-access-from-files flag. This is a security issue/risk, and users would need to visit your site/application with this already on.
  • Use the File and FileReader , or the non-standard FileSystem APIs along with a input type="file" or drag & drop

Neither of these may be applicable to your problem/solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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