DEPRECATED
Please use https://github.com/tidepool-org/webmtp instead. node-mtp
was a simple wrapper around the libmtp
library, which requires native code to run. We rewrote the MTP functions in JS so that we could also run it in the browser. webmtp
will use WebUSB in the browser, and node-usb
in Node.js.
Access devices over MTP using Node.js
On some operating systems (e.g. macOS) devices like modern Android phones do not mount as disk drives without using external software, like Android File Transfer or OSXFUSE. node-mtp
allows Node.js (v10 or higher) and Electron apps (v3.0.0 or higher) to read files from devices over MTP without requiring additional software or drivers.
node-mtp
is an N-API wrapper around the libmtp library. It uses version 3 of N-API which is only available on Node v10 and higher.
const mtp = require('node-mtp');
mtp.attach();
const list = mtp.getFileListing();
console.log('Files:', list);
mtp.getFile(8, 'test.jpg'); // <file id>, <destination>
mtp.release();
To build this on your own machine, you'll need libmtp
:
- Ubuntu:
sudo apt-get install libmtp-dev
- macOS:
brew install libmtp
The following steps will update the module on Yarn/NPM:
yarn version
git push && git push --tags
- Wait for Travis to finish.
- Download the releases from Github:
prebuildify-ci download
npm publish
Note that you need to yarn global add prebuildify-ci
to get the prebuilds.