2

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.

Harry
  • 445
  • 3
  • 11
  • 28
  • 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 Jun 08 '16 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 Jun 08 '16 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 Jun 08 '16 at 18:47
  • As per the oracle, it still supports webstart. https://java.com/en/download/faq/chrome.xml. . This change does not affect Web Start applications, it only impacts applets. Is it not true? – Harry Jun 11 '16 at 07:04

2 Answers2

1

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.

Colin
  • 2,001
  • 13
  • 28
0

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

Community
  • 1
  • 1
KpTheConstructor
  • 3,153
  • 1
  • 14
  • 22