Skip to content

Add the ability to dynamically re-assign the static "folder" (although I realised, I can use symlink as workaround) #2105

@rubyFeedback

Description

@rubyFeedback

We can set the public "folder" via set such as:

set :public_folder, __dir__ + '/static'

I would like to change the public folder, specifically to serve some video files that
are accessed only via /video/.

(I suppose I could use symlinks to the public "folder" but I find it more elegant to just
re-assign the public "folder" directve.)

Right now I am not sure how this can be done. I thought about doing so within the
route, but set() does not work there, as it only works on the toplevel. Could this
functionality be added, and also documented in the official sinatra tutorial?

I'd like to use another public directory depending on which sub-functionality
is to be used, e. g. one directory for when working with .pdf files, another one
for when working with multimedia files and so forth.

Edit: Hmm, symlinks work, so I have a workaround, even though it is not very
elegant. It works on Linux, though, not sure if that would work on windows.
So I'd still have that use case on windows. Another alternative is to probably
just set the public directory to the root of the filesystem or where I keep
those video files (e. g. /home/x/video/ also on windows, or some other
subdirectory). Not elegant but I guess this here is semi-solved.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions