Browse Source

@uppy/companion: increase max limits for remote file list operations (#4417)

* increase max limits for list operations

* fix broken test

* pageSize won't work until we get rid of permissions field

* Revert "fix broken test"

This reverts commit 70daa70276b4cdb794eb9c4b26652177b0cbff4a.

---------

Co-authored-by: Artur Paikin <artur@arturpaikin.com>
Mikael Finstad 2 năm trước cách đây
mục cha
commit
80a82756ce

+ 11 - 0
packages/@uppy/companion/src/server/provider/drive/index.js

@@ -82,6 +82,17 @@ class Drive extends Provider {
           fields: DRIVE_FILES_FIELDS,
           pageToken: query.cursor,
           q,
+          // pageSize: The maximum number of files to return per page.
+          // Partial or empty result pages are possible even before the end of the files list has been reached.
+          // Acceptable values are 1 to 1000, inclusive. (Default: 100)
+          //
+          // @TODO:
+          // SAD WARNING: doesn’t work if you have multiple `fields`, defaults to 100 anyway.
+          // Works if we remove `permissions(role,emailAddress)`, which we use to set the email address
+          // of logged in user in the Provider View header on the frontend.
+          // See https://stackoverflow.com/questions/42592125/list-request-page-size-being-ignored
+          //
+          // pageSize: 1000,
           // pageSize: 10, // can be used for testing pagination if you don't have many files
           orderBy: 'folder,name',
           includeItemsFromAllDrives: true,

+ 10 - 1
packages/@uppy/companion/src/server/provider/dropbox/index.js

@@ -29,7 +29,16 @@ async function list ({ directory, query, token }) {
     return getClient({ token }).post('files/list_folder/continue', { json: { cursor: query.cursor }, responseType: 'json' }).json()
   }
 
-  return getClient({ token }).post('files/list_folder', { searchParams: query, json: { path: `${directory || ''}`, include_non_downloadable_files: false }, responseType: 'json' }).json()
+  return getClient({ token }).post('files/list_folder', {
+    searchParams: query,
+    json: {
+      path: `${directory || ''}`,
+      include_non_downloadable_files: false,
+      // min=1, max=2000 (default: 500): The maximum number of results to return per request.
+      limit: 2000,
+    },
+    responseType: 'json',
+  }).json()
 }
 
 async function userInfo ({ token }) {