Tutorial: Work with USB flash drives

Work with USB flash drives

Subscribe to mount/unmount events:

stbEvent.onBroadcastMessage = function( from, message, data ) {
    if ( message === 'storage.mount' ) {
        console.log('mounted USB device');
    } else if ( message === 'storage.unmount' ) {
        console.log('unmounted USB device');
    }
}

Get information about all mounted USB flash drives:

var storageInfo = JSON.parse(gSTB.GetStorageInfo('{}')),
    devices = storageInfo.result || [];

console.log('USB devices:', JSON.stringify(storageInfo));

Get files and folders on the usb device:

eval(gSTB.ListDir(devices[0].mountPath));

console.log('Files:', JSON.stringify(files));
console.log('Folders:', JSON.stringify(dirs));