com.webos.service.storageaccess

API Summary

Provides a unified interface to access contents in different storage systems:

  • USB storage
  • Cloud storage provider (currently only Google Drive is supported)
  • Internal storage

Overview of the API

NA

Methods

device/copy

Description

Copies a file or directory from the source location to the destination.

Parameters

Name

Required

Type

Description

srcStorageTypeRequiredString

Indicates the source storage provider. 

Possible values are:

  • cloud
  • usb
  • internal
srcDriveIdRequiredString

Indicates the source drive ID.

Note: The drive ID can be found by using the listStorageProviders method.

srcPathRequiredString

Indicates the path of the source file or directory.

destStorageTypeRequiredString

Indicates the destination storage provider. 

Possible values are:

  • cloud
  • usb
  • internal
destDriveIdRequiredString

Indicates the destination drive ID.

Note: The drive ID can be found by using the listStorageProviders method.

destPathRequiredString

Indicates the path of the destination directory.

overwriteOptionalBoolean

Indicates if destination file must be overwritten, if it already exists.

Possible values are:

  • true: Overwrite existing copy.
  • false: Do not overwrite exisitng copy.
subscribeOptionalBoolean

Subscribe to get notified on the progress of the copy operation.

Possible values are:

  • true - Subscribed for notifications
  • false - Not subscribed

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of the operation.

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
errorCodeOptionalNumber

Indicates the error code for the failed operation.

errorTextOptionalString

Indicates the reason for the failure of the operation. See the API Error Codes Reference section for details.

Subscription Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of the operation.

progressOptionalNumber

Indicates the progress of the copy operation in percentage.

Example

# luna-send -n 1 -f luna://com.webos.service.storageaccess/device/copy '{
   "srcStorageType":"cloud",
   "srcDriveId":"ojydIxW8yBZUV8J3NiyNBvJn",
   "destStorageType":"cloud",
   "destDriveId":"ojydIxW8yBZUV8J4NiyNBvJn",
   "srcPath":"/SAF/SAF_DEMO/test1.PNG",
   "destPath":"/SAF"
}'

Response:

{
    "returnValue": true
}

# luna-send -n 1 -f luna://com.webos.service.storageaccess/device/copy '{
  "srcStorageType": "internal",
  "srcDriveId": "INTERNAL_STORAGE",
  "destStorageType": "internal",
  "destDriveId": "INTERNAL_STORAGE",
  "srcPath": "/home/guest0/source/srcfile.txt",
  "destPath": "/home/guest0/dest",
  "overwrite": true,
  "subscribe": true
}'

Response:

{
    "returnValue": true
}

Subscription Response:

{
    "returnValue": true,
    "progress": 10
}
{
    "returnValue": true,
    "progress": 40
}
{
    "returnValue": true,
    "progress": 70
}
{
    "returnValue": true,
    "progress": 100
}

device/eject

Description

Ejects the storage device. In case of "cloud" storage type, it acts as a logout operation.

Note: This operation is not applicable for "internal" storage type.

Parameters

Name

Required

Type

Description

storageTypeRequiredString

Indicates the storage provider. 

Possible values are:

  • cloud
  • usb
  • internal
driveIdRequiredString

Indicates the drive ID.

Note: The drive ID can be found by using the listStorageProviders method.

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of the operation.

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
errorCodeOptionalString

Indicates the error code for the failed operation.

errorTextOptionalString

Indicates the reason for the failure of the operation. See the API Error Codes Reference section for details.

Example

#luna-send -n 1 -f luna://com.webos.service.storageaccess/device/eject '{
   "storageType":"usb",
   "driveId":"4C531001600127113005-A7BE-1862"
}'

Response:

{
    "returnValue": true
}

device/getProperties

Description

Gets properties of the given storage provider or the specified file or directory.

Parameters

Name

Required

Type

Description

storageTypeRequiredString

Indicates the storage provider. 

Possible values are:

  • cloud
  • usb
  • internal
driveIdRequiredString

Indicates the drive ID.

Note: The drive ID can be found by using the listStorageProviders method.

pathOptionalString

Indicates the path of the file or directory.

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of the operation.

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
storageTypeOptionalString

Indicates the type of storage provider.

writableOptionalBoolean

True if the device is writable.

deletableOptionalBoolean

True if the device is deletable.

totalSpaceOptionalNumber

Total storage space

freeSpaceOptionalNumber

Available free space

attributesOptionalObject array

Array of key value pair.

Example: {"noatime": true}

Note: These is just an example format. It may vary depending on the file system.

extAttributesOptionalObject array

Array of key value pair.

Example: {"user.comment": "saf comment"}

Note: These is just an example format. It may vary depending on the file system.

errorCodeOptionalNumber

Indicates the error code for the failed operation.

errorTextOptionalString

Indicates the reason for the failure of the operation. See the API Error Codes Reference section for details.

Example

# luna-send -i -f luna://com.webos.service.storageaccess/device/getProperties '{
   "storageType":"cloud",
   "driveId":"_4Z7KLy4uyH47NwJTB5FtIoT"
}'

Response:

{
    "returnValue": true,
    "deletable": false,
    "writable": true,
    "storageType": "cloud",
    "totalSpace": 548145,
    "freeSpace": 548145
}

# luna-send -i -f luna://com.webos.service.storageaccess/device/getProperties '{
   "storageType":"internal",
   "driveId": "INTERNAL_STORAGE",
   "path":"/tmp/internal/f1.txt"
}'

Response :

{
  "returnValue": true,
  "attributes": [
    {
      "LastModTimeStamp": "Fri Jan 23 23:34:02 -150875\n"
    }
  ],
  "deletable": false,
  "writable": true,
  "storageType": "internal"
}

device/handleExtraCommand

Description

Handles addtional operation related to various providers.

Parameters

Name

Required

Type

Description

storageTypeRequiredString

Indicates the source storage provider. 

Possible values are:

  • cloud
  • usb
  • internal
driveIdOptionalString

Indicates the drive ID.

Note: The drive ID can be found by using the listStorageProviders method.

operationRequiredObject: operation

Object consisting of type and payload.

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of the operation.

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
responsePayloadOptionalObject: operation

Response from the storage provider.

errorCodeOptionalNumber

Indicates the error code for the failed operation.

errorTextOptionalString

Indicates the reason for the failure of the operation. See the API Error Codes Reference section for details.

Example

# luna-send -n 1 -f luna://com.webos.service.storageaccess/device/handleExtraCommand '{
   "storageType":"cloud",
   "operation":{
      "type":"login",
      "payload":{
         "clientId":"22054195876-t6mo0ruhd0gb.apps.googleusercontent.com",
         "clientSecret":"3OVs_ttW39gu"
      }
   }
}'

Response: 

{
   "returnValue":true,
   "responsePayload":[
      {
         "payload":{
            "response":"https://accounts.google.com/o/oauth2/auth?scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&redirect_uri=urn%3Aietfoauth%3A2.0%3Aoob&response_type=code&client_id=22054195876-t6mo0riocigrbs5d0gb.apps.googleusercontent.com&access_type=offline"
         },
         "type":"login"
      }
   ]
}

# luna-send -n 1 -f luna://com.webos.service.storageaccess/device/handleExtraCommand '{
   "storageType":"cloud",
   "driveId":"3OVs_ttW39gu",
   "operation":{
      "type":"authenticate",
      "payload":{
         "secretToken":"4/1AY0e-gmLYrDMo0affZ8"
      }
   }
}'

Response:

{
   "returnValue":true,
   "responsePayload":[
      {
         "payload":{
            "response":"1//0GmLTBDAi-abOi8amRQxLanOIj1Uwn_A3tsY"
         },
         "type":"authenticate"
      }
   ]
}

# luna-send -i -f luna://com.webos.service.storageaccess/device/handleExtraCommand '{
   "storageType":"CLOUD",
   "operation":{
      "type":"token",
      "payload":{
         "clientId":"22054195876-t6mo0ruhd0gb.apps.googleusercontent.com",
         "clientSecret":"3OVs_ttW39gu",
         "refreshToken":"1//0GmLTBDAi-abOi8amRQxLanOIj1Uwn_A3tsY"
      }
   }
}'

Response:

{
    "returnValue": true
}

device/list

Description

Lists contents of the specified directory.

Parameters

Name

Required

Type

Description

storageTypeRequiredString

Indicates the source storage provider. 

Possible values are:

  • cloud
  • usb
  • internal
driveIdRequiredString

Indicates the drive ID.

Note: The drive ID can be found by using the listStorageProviders method.

pathRequiredString

Indicates the path of the directory.

offsetRequiredNumber

Indicates the index/offset from where to list the files or directories.

limitRequiredNumber

Indicates the count of entries to be listed (1 - 100).

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of the operation.

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
filesOptionalObject array: files

Provides information of the files or directories.

totalCountOptionalNumber

Total number of files or directories in the given path.

fullPathOptionalString

Full path of this file or directory.

errorCodeOptionalNumber

Indicates the error code for the failed operation.

errorTextOptionalString

Indicates the reason for the failure of the operation. See the API Error Codes Reference section for details.

Example

# luna-send -n 1 -f luna://com.webos.service.storageaccess/device/list '{
   "storageType":"cloud",
   "driveId":"ojydIxW8yBZUV8J3NiyNBvJn",
   "path":"/saf_demo_folder",
   "limit":10,
   "offset":1
}'

Response:

{
    "returnValue": true,
    "totalCount": 2,
    "fullPath": "/saf_demo_folder",
    "file": [
        {
            "size": 0,
            "type": "directory",
            "mimeType": "application/vnd.google-apps.folder",
            "path": "/saf_demo_folder/SAF",
            "name": "SAF"
        },
        {
            "size": 548146,
            "type": "regular",
            "mimeType": "application/pdf",
            "path": "/saf_demo_folder/invoice.pdf",
            "name": "invoice.pdf"
        }
    ]
    
}

device/move

Description

Moves a file or directory from the source location to the destination.

Parameters

Name

Required

Type

Description

srcStorageTypeRequiredString

Indicates the source storage provider. 

Possible values are:

  • cloud
  • usb
  • internal
srcDriveIdRequiredString

Indicates the source drive ID.

Note: The drive ID can be found by using the listStorageProviders method.

destStorageTypeRequiredString

Indicates the destination storage provider. 

Possible values are:

  • cloud
  • usb
  • internal
destDriveIdRequiredString

Indicates the destination drive ID.

Note: The drive ID can be found by using the listStorageProviders method.

srcPathRequiredString

Indicates the path of the source file or directory.

destPathRequiredString

Indicates the path of the destination directory.

overwriteOptionalBoolean

Indicates if destination file must be overwritten, if it already exists.

Possible values are:

  • true: Overwrite existing copy.
  • false: Do not overwrite exisitng copy.
subscribeOptionalBoolean

Subscribe to get notified on the progress of the copy operation.

Possible values are:

  • true - Subscribed for notifications
  • false - Not subscribed

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of the operation.

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
errorCodeOptionalNumber

Indicates the error code for the failed operation

errorTextOptionalString

Indicates the reason for the failure of the operation. See the API Error Codes Reference section for details.

Subscription Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of the operation.

    progressOptionalNumber

    Indicates the progress of the copy operation in percentage.

    Example

    # luna-send -n 1 -f luna://com.webos.service.storageaccess/device/move '{
       "srcStorageType":"cloud",
       "srcDriveId":"ojydIxW8yBZUV8J3NiyNBvJn",
       "destStorageType":"cloud",
       "destDriveId":"ojydIxW8yBZUV8J3NiyNBvJn",
       "srcPath":"/SAF/SAF_DEMO/test1.PNG",
       "destPath":"/SAF"
    }'

    Response:

    {
        "returnValue": true
    }

    # luna-send -n 1 -f luna://com.webos.service.storageaccess/device/move '{
      "srcStorageType": "internal",
      "srcDriveId": "INTERNAL_STORAGE",
      "destStorageType": "internal",
      "destDriveId": "INTERNAL_STORAGE",
      "srcPath": "/home/guest0/source/srcfile.txt",
      "destPath": "/home/guest0/dest",
      "overwrite": true,
      "subscribe": true
    }'

    Response:

    {
        "returnValue": true
    }

    Subscription Response:

    {
        "returnValue": true,
        "progress": 10
    }
    {
        "returnValue": true,
        "progress": 40
    }
    {
        "returnValue": true,
        "progress": 70
    }
    {
        "returnValue": true,
        "progress": 100
    }

    device/remove

    Description

    Deletes the specified file or directory.

    Parameters

    Name

    Required

    Type

    Description

    storageTypeRequiredString

    Indicates the storage provider. 

    Possible values are:

    • cloud
    • usb
    • internal
    driveIdRequiredString

    Indicates the drive ID.

    Note: The drive ID can be found by using the listStorageProviders method.

    pathRequiredString

    Inddicates the path of the file or directory.

    Call Returns

    Name

    Required

    Type

    Description

    returnValueRequiredBoolean

    Indicates the status of the operation.

    • true: Indicates that the operation was successful.
    • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
    errorCodeOptionalString

    Indicates the error code for the failed operation.

    errorTextOptionalString

    Indicates the reason for the failure of the operation. See the API Error Codes Reference section for details.

    Example

    # luna-send -n 1 -f luna://com.webos.service.storageaccess/device/remove '{
      "storageType": "cloud",
      "driveId": "ojydIxW8yBZUV8J3NiyNBvJn",
      "path": "/SAF/test1.PNG"
    }'

    Response:

    {
        "returnValue": true
    }

    device/rename

    Description

    Renames the specified file or directory.

    Parameters

    Name

    Required

    Type

    Description

    storageTypeRequiredString

    Indicates the storage provider. 

    Possible values are:

    • cloud
    • usb
    • internal
    driveIdRequiredString

    Indicates the drive ID.

    Note: The drive ID can be found by using the listStorageProviders method.

    pathRequiredString

    Indicates the path of the file or directory.

    newNameRequiredString

    Indicates the new name.

    Call Returns

    Name

    Required

    Type

    Description

    returnValueRequiredBoolean

    Indicates the status of the operation.

    • true: Indicates that the operation was successful.
    • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
    errorCodeOptionalNumber

    Indicates the error code for the failed operation

    errorTextOptionalString

    Indicates the reason for the failure of the operation. See the API Error Codes Reference section for details.

    Example

    # luna-send -n 1 -f luna://com.webos.service.storageaccess/device/rename '{
       "storageType":"cloud",
       "driveId":"ojydIxW8yBZUV8J3NiyNBvJn",
       "path":"/SAF/test1.PNG",
       "newName":"17.PNG"
    }'

    Response:

    {
        "returnValue": true
    }

    listStorageProviders

    Description

    Provides a list of storages providers and the corresponding drive information.

    Parameters

    Name

    Required

    Type

    Description

    subscribeOptionalBoolean

    Subscribe to get notifications.

    Possible values are:

    • true - Subscribed for notifications
    • false - Not subscribed

    Call Returns

    Name

    Required

    Type

    Description

    returnValueRequiredBoolean

    Indicates the status of the operation.

    • true: Indicates that the operation was successful.
    • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
    subscribeOptionalBoolean

    Indicates if subscribed to get notifications.

    storageProvidersOptionalObject array: storageProviders

    Provides information of the storage providers.

    errorCodeOptionalNumber

    Indicates the error code for the failed operation

    errorTextOptionalString

    Indicates the reason for the failure of the operation. See the API Error Codes Reference section for details.

    Example

    # luna-send -n 1 -f luna://com.webos.service.storageaccess/listStorageProviders '{"subscribe": true}'

    Response:

    {
       "returnValue":true,
       "storageProviders":[
          {
             "usb":[
                {
                   "driveName":"sdg2",
                   "driveId":"4C531001600127113005-A7BE-1862",
                   "path":"/tmp/usb_rse_right/sdg2",
                   "fileSystem":"vfat"
                },
                {
                   "driveName":"sdg1",
                   "driveId":"4C531001600127113005-A6B3-2892",
                   "path":"/tmp/usb_rse_right/sdg1",
                   "fileSystem":"vfat"
                }
             ]
          },
          {
             "internal":[
                {
                   "driveName":"INTERNAL",
                   "driveId":"INTERNAL_STORAGE",
                   "path":"/tmp/internal"
                }
             ]
          },
          {
             "cloud":[
                {
                   "driveName":"GDRIVE",
                   "driveId":"ojydIxW8yBZUV8J3NiyNBvJn",
                   "path":"/"
                }
             ]
          }
       ]
    }

    # luna-send -i -f luna://com.webos.service.storageaccess/listStorageProviders '{"subscribe": true}'

    Response:

    {
      "returnValue": true,
      "storageProviders": [
        {
          "usb": [
            {
              "path": "/tmp/usb_guest0/sdg1",
              "driveName": "sdg1",
              "driveId": "4C531001460127113020-B23A-EBFD",
              "fileSystem": "vfat"
            }
          ]
        },
        {
          "internal": [
            {
              "path": "/tmp/internal",
              "driveName": "INTERNAL",
              "driveId": "INTERNAL_STORAGE"
            }
          ]
        },
        {
          "cloud": [
            {
              "path": "/",
              "driveName": "GDRIVE",
              "driveId": "ojydIxW8yBZUV8J4NiyNBvJn"
            }
          ]
        }
      ]
    }

    Subscription Response:

    {
      "returnValue": true,
      "storageProviders": [
        {
          "usb": []
        },
        {
          "internal": [
            {
              "path": "/tmp/internal",
              "driveName": "INTERNAL",
              "driveId": "INTERNAL_STORAGE"
            }
          ]
        },
        {
          "cloud": [
            {
              "path": "/",
              "driveName": "GDRIVE",
              "driveId": "ojydIxW8yBZUV8J4NiyNBvJn"
            }
          ]
        }
      ]
    }

    Objects

    storageProviders

    Provides information about the storage provider.

    Name

    Required

    Type

    Description

    driveIdRequiredString

    Indicates the drive ID.

    Note: For internal storage the ID is INTERNAL_STORAGE.

    driveNameRequiredString

    Indicates the drive name.

    Note: For internal storage the name is INTERNAL and for cloud currently only GDRIVE (Google Drive) is supported.

    pathRequiredString

    Indicates the path of the drive.

    fileSystemOptionalString

    Indicates the file system type (only in case of USB).

    files

    Provides information of the file or directory.

    Name

    Required

    Type

    Description

    nameRequiredString

    Indicates the file name.

    typeRequiredString

    Indicates the type of file.

    Possible values are:

    • directory
    • regular
    • linkfile
    • unknown
    • and so on
    pathRequiredString

    Inidcates the path of the file or directory.

    sizeRequiredString

    Indicates the size in bytes.

    mimeTypeOptionalString

    Indicates the mime type of the file.

    operation

    Provides details of the operation.

    Name

    Required

    Type

    Description

    typeRequiredString

    Indicates the type of operation. For example, login, authenticate, token, adn so on.

    payloadRequiredObject

    Details of the operation.

    API Error Codes Reference

    Error Code

    Error Text

    Error Description

    8013Operation not permitted

    Operation not permitted.

    6008Already Authenticated

    Already Authenticated

    6006Cloud Not Attached

    Cloud Not Attached

    8017File exists

    File exists

    6010File Not Supported

    File Not Supported

    8003Invalid parameter

    Invalid parameter

    6009Invalid URL

    Invalid URL

    8016No such file or directory at Destination

    No such file or directory at Destination

    8015No such file or directory at Source

    No such file or directory at Source

    8014No such file or directory

    No such file or directory

    9004No USB drive found

    No USB drive found

    9003No USB Storage Exists with ID given

    No USB Storage Exists with ID given

    6007Permission denied

    Permission denied

    8000Unknown error

    Unknown error

    9002USB Storage has more partition

    USB Storage has more partition

    Contents