Backendless Support
 
Answered

Files.listing not showing all files and folders

Hello again!

I'm now using the File API, and maybe I'm doing something wrong, but I can't list all the files of my storage. I do the following, and the files/folders appear, but only 10 items are shown. If I do the same inside a folder, the same occurs, only 10 items are shown, but no more:

  1. private void getFiles() {
  2. Backendless.Files.listing("/", "*", true, new AsyncCallback<BackendlessCollection<FileInfo>>() {
  3. @Override
  4. public void handleResponse(BackendlessCollection<FileInfo> response) {
  5. Iterator<FileInfo> filesIterator = response.getCurrentPage().iterator();
  6. while (filesIterator.hasNext()) {
  7. FileInfo file = filesIterator.next();
  8. String URL = file.getURL();
  9. String publicURL = file.getPublicUrl();
  10. Date createdOn = new Date(file.getCreatedOn());
  11. String name = file.getName();
  12. Log.d("Files/Folders", URL + " " + publicURL + " " + createdOn + " " + name);
  13. }
  14. }
  15. @Override
  16. public void handleFault(BackendlessFault fault) {
  17. Log.d("Error", "An error has occurred.");
  18. }
  19. });
  20. }

Best Answer
photo

Ok, sorry , the documentation says:

"Return value:

A collection of files and directories matching the specified pattern For

the method(s) without the pattern. The returned collection may not

include all files and directories as the size of the number of returned

entries is limited for paging purposes. The collection object includes a

property called totalObjects, which

indicated how many files and directories in total may be returned for

the given pattern by multiple paging requests. To get the next set of

file/directory entries, an additional request must be made with a

different offset value."

So I only have to use pagesize and offset variables correctly.

Thanks

Leave a Comment

Comments (2)

photo
1

Ok, sorry , the documentation says:

"Return value:

A collection of files and directories matching the specified pattern For

the method(s) without the pattern. The returned collection may not

include all files and directories as the size of the number of returned

entries is limited for paging purposes. The collection object includes a

property called totalObjects, which

indicated how many files and directories in total may be returned for

the given pattern by multiple paging requests. To get the next set of

file/directory entries, an additional request must be made with a

different offset value."

So I only have to use pagesize and offset variables correctly.

Thanks

photo
2

Can u make that clear sir, I have the same problem.

What should I give as offset, on giving offset as 0 it gives only the first element.

Show us ur new code if possible.

Thank you

photo