javascript - How to access USB device in chrome? - Stack Overflow

admin2025-04-17  0

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 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.

Share asked Jun 8, 2016 at 17:26 HarryHarry 5053 gold badges13 silver badges34 bronze badges 4
  • 3 Web apps don't have access to the file system. You can't copy files from a browser-bound application with the possible exception of browser extensions. – Mike Cluck Commented Jun 8, 2016 at 17:27
  • I can add a applet and it will give me permission to read and write from usb drive, but applet is no longer supported in chrome. so any alternative to it? Can I use webstart? – Harry Commented Jun 8, 2016 at 17:34
  • No, Web Start uses the same thing. In short, it's impossible to directly access the users machine from inside of Chrome anymore. You would need to have the user install an extension or some other external program. – Mike Cluck Commented Jun 8, 2016 at 18:47
  • As per the oracle, it still supports webstart. java./en/download/faq/chrome.xml. . This change does not affect Web Start applications, it only impacts applets. Is it not true? – Harry Commented Jun 11, 2016 at 7:04
Add a ment  | 

2 Answers 2

Reset to default 1

Chrome 61+ has an implementation of the WebUSB API

This would not let you issue a mand 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.

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

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

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

Hope this helps

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1744884272a272442.html

最新回复(0)