Is there a way to get all the files and the folder in the field without knowing their identifier?

Is there a way to get all the files and the folder in the field without knowing their identifier? Also, how to get all collaboration objects if I don’t know the collaboration identifier?

+4
source share
4 answers

You can get the root folders and files by specifying the folder id = 0. And with this result, you can also get additional folders or files.

+9
source

You can use Get Folder Files in the folder identifier that you know to retrieve the identifiers of the folders and files that it contains. As Shanky says, use 0 to run in the root folder.

Get Collaborations will show collaboration in the folder. You do not need any cooperation information, just a folder identifier.

+1
source

Unlike systems that are built exclusively on the access path, Box gives you a strong identifier for each folder and file. This has several advantages. One of the biggest is that you can rename or move the file, and you never need to change to get to it. It also means that you can save identifiers, associate them with some other object in your own system and still be able to return to the same file or folder. Assuming you still have access to it. Of course, permissions can also change.

You can get all the collaboration for the user by calling GET / collaboration or all cooperative actions in the folder by calling GET / folder / ID / collaboration

0
source

Call List FilesInBoxFolders ("0") ---> This will analyze all files and folders, starting with root

public void listFilesInBoxFolders(String folderId) { try { // get a list of songs BoxApiFolder folderApi = new BoxApiFolder(mSession); BoxListItems items = folderApi.getItemsRequest(folderId).send(); JSONObject object = new JSONObject(items.toJson()); LogUtils.log(TAG, "Object " + object.toString()); JSONArray array = object.getJSONArray("entries"); for (int i = 0; i < array.length(); i++) { JSONObject object1 = array.getJSONObject(i); String type = object1.getString("type"); String id = object1.getString("id"); String name = object1.getString("name"); if (type.equals("folder")) { listFilesInBoxFolders(id); } else if (type.equals("file")) { // Supported Media file types if (name.contains("mp3") || name.contains("m4a") || name.contains("flac")) { musicItems.add(new BoxMusicItem(id, name)); } } } LogUtils.log(TAG, "array " + array.toString()); } catch (BoxException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); LogUtils.log(TAG, "Json Error"); } // For testing to make sure i have all files in box printFilesInBox(); } 
0
source

Source: https://habr.com/ru/post/1480847/


All Articles