File/Folder navigation

Contents

File browsing is one of the core functionalities of My Cloud Home, which allows a user to navigate between folders in the device. My Cloud Home uses object store model for storing data. All the files and folders in the My Cloud Home are independent objects and are identified and retrieved by its Object ID. The file (or folder) object contains all its metadata, including its Parent ID. Parent ID is the metadata attribute that helps to maintain file hierarchy. Unlike file storage systems, the objects are stored in a flat structure.

The root folder ID of the device is always 'root'. When making a file browsing API call for a given ID, My Cloud Home API will return a list of files and folders in the requested folder ID. The client application can retrieve the folder IDs from the return list and navigate to the selected folder. Here is an example code for root level folder listing.


  GET /sdk/v2/filesSearch/parents?ids=root HTTP/1.1
  Host: Endpoint-URL
  Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGci

  200 OK
  {
    "pageToken": "",
    "files": [
      {
        "id": "t86N5pOCXZEjw0CdMc4K9aiU5MJe49etZY0tkKyf",
        "parentID": "DYUc6hIi2J2DrIz-UZUVm43iTGBcot27UywMovGn",
        "eTag": "\"Ag\"",
        "childCount": 12,
        "mimeType": "application/x.wd.dir",
        "name": "Campo di Bocce",
        "mTime": "2017-01-31T02:11:56.94Z",
        "cTime": "2017-01-31T02:11:56.94Z",
        "storageType": "local",
        "hidden": "none"
      },
      {
        "id": "MioeRB24H-CUOXeuJbt5sr5HCSNN0UKaNMIfWmUr",
        "parentID": "DYUc6hIi2J2DrIz-UZUVm43iTGBcot27UywMovGn",
        "eTag": "\"Ag\"",
        "childCount": 4,
        "mimeType": "application/x.wd.dir",
        "name": "Dance",
        "mTime": "2017-01-26T02:05:45.592Z",
        "cTime": "2017-01-26T02:05:45.592Z",
        "storageType": "local",
        "hidden": "none"
      }
    ]
  }

Observe that the ID used in the request is 'root', which means the request is for getting the files of the root folder of a given user. The requesting user will be detected automatically from the token used in the 'Authorization' header. The folder object is differentiated from the other file object using "application/x.wd.dir" MIME type. As you have observed in the above example, the two items returned for root folder are:

  • file type with "mimeType": "application/x.wd.dir" and
  • file name with "names": "Campo di Bocce" and "Dance"

The number of items that each folder contains is returned using "childCount". You can navigate to one of these subfolders using the same API.


  GET /sdk/v2/filesSearch/parents?ids=MioeRB24H-CUOXeuJbt5sr5HCSNN0UKaNMIfWmUr HTTP/1.1
  Host: Endpoint-URL
  Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGci

  200 OK
  {
     "pageToken":"",
     "files":[
        {
           "id":"h76Kh7Fj1AD5ipZa9HthreG-pY5oaar1Gs_69iGC",
           "parentID":"MioeRB24H-CUOXeuJbt5sr5HCSNN0UKaNMIfWmUr",
           "eTag":"\"Ag\"",
           "size":6844,
           "mimeType":"image/png",
           "name":"CloudSync.png",
           "mTime":"2017-02-06T19:49:44Z",
           "cTime":"2017-02-07T19:51:29.886Z",
           "storageType":"local",
           "extension":".png",
           "hidden":"none",
           "image":{
              "width":180,
              "height":180
           }
        },
        {
           "id":"ca0-i69xh_CGYwTaIgfdaJsJwIU6gKTdfjQLxV1h",
           "parentID":"MioeRB24H-CUOXeuJbt5sr5HCSNN0UKaNMIfWmUr",
           "eTag":"\"Ag\"",
           "size":465,
           "mimeType":"application/octet-stream",
           "name":"data.csv",
           "mTime":"2016-04-07T23:36:24Z",
           "cTime":"2017-02-07T19:51:17.751Z",
           "storageType":"local",
           "extension":".csv",
           "hidden":"none"
        },
        {
           "id":"Rxk7ex3gFXkJndk-xLoqdXhX1CBGVzmroaQM91fp",
           "parentID":"MioeRB24H-CUOXeuJbt5sr5HCSNN0UKaNMIfWmUr",
           "eTag":"\"Ag\"",
           "size":22153,
           "mimeType":"text/plain; charset=utf-8",
           "name":"performance.txt",
           "mTime":"2016-04-06T23:18:33Z",
           "cTime":"2017-02-07T19:51:49.734Z",
           "storageType":"local",
           "extension":".txt",
           "hidden":"none"
        },
        {
           "id":"mkBZrz9Qj_-7plqdxximhInL9FCp1BRkZVqZY8y1",
           "parentID":"MioeRB24H-CUOXeuJbt5sr5HCSNN0UKaNMIfWmUr",
           "eTag":"\"Ag\"",
           "size":634035,
           "mimeType":"image/jpeg",
           "name":"profile_pic.jpeg",
           "mTime":"2016-10-12T23:10:27Z",
           "cTime":"2017-02-07T19:51:38.088Z",
           "storageType":"local",
           "extension":".jpeg",
           "hidden":"none",
           "image":{
              "date":"2016:10:01 16:18:04",
              "width":1688,
              "height":1364,
              "cameraMake":"Motorola",
              "cameraModel":"XT1575",
              "aperture":2,
              "exposureTime":0.00786,
              "isoSpeed":64,
              "focalLength":2.35,
              "flashFired":false,
              "orientation":1
           }
        }
     ]
  }

As you will have noticed, different types of files have different mime types and different metadata. You should use mimeType to detect the file type and extract metadata accordingly. For example, "mimeType":"image/*" will have "image" property with varying level information like height, width and camera details.

APIs

Have question about this section?