Skip to content

Files endpoint uploads one file per form submission #952

Description

@rmdes

The upload form in @indiekit/endpoint-files accepts a single file: the input has no multiple attribute, and formController.post (lib/controllers/form.js) reads request.files.file as one object. Uploading a set of photos for a post means repeating the form once per file.

Nothing in the stack prevents several: express-fileupload returns an array for a repeated file field, and the media endpoint takes one file per request, so the controller only needs to loop. This is the no-JavaScript half of #722 (the form there is a different question, about adding fieldsets to the post form).

Fix: add multiple to the input; in the controller, treat request.files.file as one file or an array, upload each in turn (in turn rather than concurrently, since a Git-backed store may not accept parallel writes, see #792), and report: the media endpoint's own message for one file, “%s files uploaded” for several, “%s of %s files uploaded” when some failed, and the error page only when none succeeded. PR to follow.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions