开发者控制台
感谢您的访问。此页面目前仅提供英语版本。我们正在开发中文版本。谢谢您的理解。

SDK for iOS Listing Nodes

Listing nodes using the SDK for iOS

Getting Node Information

All of the data associated with files and folders in Amazon Drive is represented as nodes. Learn more about nodes in the SDK overview.

Get a Specific Node

To retrieve a specific node, use the[ACDSKClient getNode:...] method.

  // Get a single node with given nodeID
  ACDSKGetNodeRequest *getNodeRequest = [ACDSKGetNodeRequest new];
  getNodeRequest.nodeID = nodeID;

  // Make asynchronous request using instance of ACDSKClient
  [client getNode:getNodeRequest fail:^(NSError *error) {
      // Handle failure
  } success:^(ACDSKGetNodeResponse *response) {
      // Handle success
      // response consists of a ACDSKNode
  }];

Listing Nodes

You may list multiple nodes all at once. This is accomplished with one of the [ACDSKClient list...] methods.

  • Use the listNodes:... method to list nodes in the general case, such as to meet a filter criteria.
  • Use the listChildren:... method to list nodes that are children of a parent, such as files in a folder.
  • Use the listNodesInTrash:... method to list nodes that are in the trash.

All of the [ACDSKClient list...] methods are paginated, meaning that you may not get all of the matching nodes back in one response. To get all of the data, you must make additional requests with the startToken parameter set to the value of the nextToken received in the previous response. You should continue to do this until the nextToken comes back as nil. A nextToken is valid for 10 minutes before it expires.

List Nodes

To retrieve multiple nodes in the general case, use the [ACDSKClient listNodes:...] method.

  // List folder nodes
  ACDSKListNodesRequest *request = [ACDSKListNodesRequest new];
  request.filters = @"kind:FOLDER";

  // Make asynchronous request using instance of ACDSKClient
  [client listNodes:request fail:^(NSError *error) {
      // Handle failure
  } success:^(ACDSKListNodesResponse *response) {
      // Handle success
      // response.data is a NSArray of ACDSKNode objects

      // Check next token for more data to retrieve
      NSString *nextToken = response.nextToken;
      if (nextToken != nil) {
          // Make another request
          ACDSKListNodesRequest *requestNext = [ACDSKListNodesRequest new];
          requestNext.filters = @"kind:FOLDER";
          requestNext.startToken = nextToken;
          // ...
      }
  }];

List Children

It is easy to list the contents of a folder using the [ACDSKClient listChildren:...] method.

  // List files in a given folder
  ACDSKListChildrenRequest *request = [ACDSKListChildrenRequest new];
  request.parentID = folderID;
  request.filters = @"kind:FILE";

  // Make asynchronous request using instance of ACDSKClient
  [client listChildren:request fail:^(NSError *error) {
      // Handle failure
  } success:^(ACDSKListChildrenResponse *response) {
      // Handle success
      // response.data is a NSArray of ACDSKNode objects

      // Check next token for more data to retrieve
      NSString *nextToken = response.nextToken;
      if (nextToken != nil) {
          // Make another request
          ACDSKListChildrenRequest *requestNext = [ACDSKListChildrenRequest new];
          requestNext.parentID = folderID;
          requestNext.filters = @"kind:FILE";
          requestNext.startToken = nextToken;
          // ...
      }
  }];

List Nodes in Trash

To list the contents of the trash, use the [ACDSKClient listNodesInTrash:…] method.

  // List contents of the trash
  ACDSKListNodesInTrashRequest *request = [ACDSKListNodesInTrashRequest new];

  // Make asynchronous request using instance of ACDSKClient
  [client listNodesInTrash:request fail:^(NSError *error) {
      // Handle failure
  } success:^(ACDSKListNodesInTrashResponse *response) {
      // Handle success
      // response.data is a NSArray of ACDSKNode objects

      // Check next token for more data to retrieve
      NSString *nextToken = response.nextToken;
      if (nextToken != nil) {
          // Make another request
          ACDSKListNodesInTrashRequest *requestNext = [ACDSKListNodesInTrashRequest new];
          requestNext.startToken = nextToken;
          // ...
      }
  }];

Listing with Filters

Various types of filters can be used with any of the list requests to find the specific type of Amazon Drive node for which you are searching. For more information about filtering nodes, see the filtering section of the RESTful Amazon Drive API.

Support

If you have any questions, see the Developer Forum.