I was discussing this with @ParisLiakos in IRC.


I need to be able to link to a file entity directly and display it inline just like you were making a link to sites/default/files/some.pdf. I don't want it to prompt the user to save the file like it does with file/%/download.

Proposed resolution

With this feature we could have something like file/244/download/attachment or file/244/download/inline, but we could also keep the default of file/244/download.

@ParisLiakos also mentioned:

leveraging hook_menu
eg like an alias
file//download == file//download/attachment

He also mentioned that there are several different content dispositions listed at http://www.iana.org/assignments/cont-disp/cont-disp.xml, but the top two "inline and attachment" are the most commonly used.


Couple of other things to consider:

How do we link to file from a menu item without hardcoding the link? #2023741: Allow file entities to be menu items
- maybe link to file/id/download - not sure if you can do this now that file_entity has a file has token protection #1995154: Add token protection to file/%file/download callback?
- if you hardcode the link then the link will break if the file gets moved to a different directory

How do we link to a file using a link field using the link module without hardcoding the link? If the file gets moved to different directory then the link will break.
- not sure about this one?

How do we link directly to a file inside the wysiwyg editor?
-Could use https://drupal.org/project/portable_path + https://drupal.org/project/linkit
-Could use https://drupal.org/project/ckeditor_link + https://drupal.org/project/ckeditor_link_file

Discussions in IRC:
Dave Reid was concerned that a file/id/download/inline callback could be exploited just like what was mentioned in #1995154: Add token protection to file/%file/download callback?
Dave Reid said we can't change file ids to be randomly generated when a file is added.