whale.system.storage

Description: Use the whale.system.storage API to query storage device information and be notified when a removable storage device is attached and detached.
Availability: Since Chrome 30.
Permissions: "system.storage"
## Summary | Types | |---| | [StorageUnitInfo](#type-StorageUnitInfo) | | Methods | | [getInfo](#method-getInfo) − `whale.system.storage.getInfo(function callback)` | | [ejectDevice](#method-ejectDevice) − `whale.system.storage.ejectDevice(string id, function callback)` | | [getAvailableCapacity](#method-getAvailableCapacity) − `whale.system.storage.getAvailableCapacity(string id, function callback)` | | Events | | [onAttached](#event-onAttached) | | [onDetached](#event-onDetached) |
## Types
### StorageUnitInfo | properties | |---| | string | id | The transient ID that uniquely identifies the storage device. This ID will be persistent within the same run of a single application. It will not be a persistent identifier between different runs of an application, or between different applications. | | string | name | The name of the storage unit. | | enum of `"fixed"`, `"removable"`, or `"unknown"` | type | The media type of the storage unit.
fixed
The storage has fixed media, e.g. hard disk or SSD.
removable
The storage is removable, e.g. USB flash drive.
unknown
The storage type is unknown.
| | double | capacity | The total amount of the storage space, in bytes. |
## Methods
### getInfo
`whale.system.storage.getInfo(function callback)`
Get the storage information from the system. The argument passed to the callback is an array of StorageUnitInfo objects. | Parameters | |---| | function | callback | The _callback_ parameter should be a function that looks like this: `function(array of [StorageUnitInfo](/extensions/system.storage#type-StorageUnitInfo) info) {...};` | array of [StorageUnitInfo](/extensions/system.storage#type-StorageUnitInfo) | info | | |---|---|---| |
### ejectDevice
`whale.system.storage.ejectDevice(string id, function callback)`
Ejects a removable storage device. | Parameters | |---| | string | id | | | function | callback | The _callback_ parameter should be a function that looks like this: `function(enum of `"success"`, `"in_use"`, `"no_such_device"`, or `"failure"` result) {...};` | enum of `"success"`, `"in_use"`, `"no_such_device"`, or `"failure"` | result | |---|---|
success
The ejection command is successful -- the application can prompt the user to remove the device.
in_use
The device is in use by another application. The ejection did not succeed; the user should not remove the device until the other application is done with the device.
no_such_device
There is no such device known.
failure
The ejection command failed.
| |
### getAvailableCapacity
`whale.system.storage.getAvailableCapacity(string id, function callback)`
**Dev** channel only. [Learn more](api_index#dev_apis). Get the available capacity of a specified |id| storage device. The |id| is the transient device ID from StorageUnitInfo. | Parameters | |---| | string | id | Since Chrome 32. | | function | callback | The _callback_ parameter should be a function that looks like this: `function(object info) {...};` | object | info | |---|---| | string | id | |---|---| A copied |id| of getAvailableCapacity function parameter |id|. | | double | availableCapacity | The available capacity of the storage device, in bytes. | | |
## Events
### onAttached
Fired when a new removable storage is attached to the system.
#### addListener
`whale.system.storage.onAttached.addListener(function callback)`
| Parameters | |---| | function | callback | The _callback_ parameter should be a function that looks like this: `function( [StorageUnitInfo](/extensions/system.storage#type-StorageUnitInfo) info) {...};` | [StorageUnitInfo](/extensions/system.storage#type-StorageUnitInfo) | info | | |---|---|---| |
### onDetached
Fired when a removable storage is detached from the system.
#### addListener
`whale.system.storage.onDetached.addListener(function callback)`
| Parameters | |---| | function | callback | The _callback_ parameter should be a function that looks like this: `function(string id) {...};` | string | id | | |---|---|---| |

results matching ""

    No results matching ""