Folders in media library

Hi @dhwind,
I created global middleware file in the src/middlewares folder.

// src/middlewares/uploadMiddleware.js
"use-strict";

module.exports = (config, { strapi }) => {
  return async (ctx, next) => {
    // Only run this middleware for the upload endpoint
    if (ctx.url.startsWith("/upload") && ctx.method === "POST") {
      if (ctx.request.body) {
        try {
          const fileInfo = JSON.parse(ctx?.request?.body?.fileInfo);
          const extension = fileInfo.name.split(".").pop().toLowerCase();
          if (extension == "pdf") {
            fileInfo["folder"] = 4;
          } else {
            fileInfo["folder"] = 3;
          }
          ctx.request.body.fileInfo = JSON.stringify(fileInfo);

        } catch (error) {
          console.error("Error parsing or modifying fileInfo:", error);
        }
      }
    }

    // Continue to the next middleware
    await next();
  };
};

And update config/middlewares.js file.

`module.exports = [
   // rest middlewares
  "global::uploadMiddleware",
   // rest middleware
];
`

But before that, we have to create folders in the media library. folder name will be 1,2,3,4,… according to folder creation order. Then it will save according to logic in middleware.