Skip to content

Support Content-Disposition HTTP response header #447

@Syndesi

Description

@Syndesi

The Content-Disposition HTTP response header can be used to transmit the file's name, including its file extension.

Within Ember Nexus, it should work in the following way:

  • The Content-Disposition HTTP header is always set to attachment; filename="<name>.<extension>"
  • The file name is decided by priority, starting with the following option:
    • The name-property of the current element, if it a) exists and b) is of type string.
    • The id of the current element, in string form.
  • The extension is decided through the following options (already calculated during upload):
    • The original file extension, if the original upload contained a Content-Disposition header on its own.
    • A file extension determined by mime type lookup of the file itself.
    • If the extension can not be determined, the fallback extension .bin is used.
  • The following constraints are placed on the file name:
    • The whole file name, i.e. <name>.<extension>, is limited to 255 characters - a normal limit by filesystems like NTFS, Btrfs, ext4 and exFAT are all limited to 256 bytes / chars. See also Wikipedia list of file system limits.
    • If the file name limit is exceeded, then the name part is truncated from the right as much as required. The extension itself can not be truncated.
    • Special characters need to be removed from the file name, notably: "*/:<>?\| source, Wikipedia

Note: The filename can not be directly changed by clients; they can only change the element's name. The file extension itself is linked to the representation, which can only be changed by re-uploading the file (or another representation).

Acceptance criteria:

  • The Content-Disposition HTTP header is supported for file uploads.
  • The Content-Disposition HTTP header is supported for file downloads.
  • The file name is correctly generated, sanitized and truncated.
  • Unit tests.
  • Feature tests.
  • Documentation.
  • Todo: What about the RFC 5987 filename encoding? Should we support it? Is it easy to support?

See also:

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureIntroducing new capabilities.

    Type

    No type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions