Pagination not working for "api/upload/files" endpoint

System Information
  • Strapi Version: v4:
  • Operating System: Mac:
  • Database: MySQL:
  • Node Version: v14:
  • NPM Version: 8.3.1:

The upload plugin does not support pagination. Anyone know a work around for this?

Files endpoint

Pagination works fine for normal APIs I create. example:
custom folders api - working fine

Anyone know how to fix?

I got it to work by using

  start: 10,
  limit: 15,

Any answer to this problem please?

Just an extra for anyone who can edit their backend, you can make the files endpoint more like other api endpoints:

Inside: src/index.js

// make the register block look like this:
  register({ strapi }) {
    strapi.plugin("upload").controllers["content-api"].find = async function (ctx) {
      const { start, limit } = ctx.query
      const firstPageAdd = start > limit ? 0 : 1
      const files = await strapi.plugin("upload").services.upload.findMany(ctx.query);
      const total = await strapi.db.query('plugin::upload.file').count(ctx.query)
      const data = await sanitizeOutput(files, ctx)
      ctx.body = {
        data, pagination: { pageCount: files.length, pageSize: limit, total, page: Math.ceil(((start - firstPageAdd) / limit) + 1) }

remember to import sanitizeOutput

Thanks, this works for fetching the items but there is no additional pagination meta sent in the response, like the total number of records.