Discussion:
Any options for serving files from outside of public?
French Fry
2017-10-25 21:37:57 UTC
Permalink
I want to be able to play audio files that are outside root. I've been
reading around and it looks like options are non-existent. Even if I set
additional public folders, the files span multiples directories (and
drives). I looked at Rack::TryStatic but it looks like I'd have to
downgrade Rack, from 2.x to 1.7. Doesn't sound like a good idea.

So I'm just throwing this out. Maybe something I'm not aware of yet.

Thanks
FF
--
You received this message because you are subscribed to the Google Groups "sinatrarb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sinatrarb+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jason Rogers
2017-10-26 03:10:43 UTC
Permalink
The first argument to *send_file* can be an absolute or relative path. E.g.


get '/absolute' *do*
send_file *"*/absolute/path/to/pic.jpg*"*, disposition: *"*inline*"*
*end*

get '/relative' *do*
send_file *"*../../../relative/path/to/pic.jpg*"*, disposition: *"*inline
*"*
*end*


Does that help?


--
Jason Rogers
Post by French Fry
I want to be able to play audio files that are outside root. I've been
reading around and it looks like options are non-existent. Even if I set
additional public folders, the files span multiples directories (and
drives). I looked at Rack::TryStatic but it looks like I'd have to
downgrade Rack, from 2.x to 1.7. Doesn't sound like a good idea.
So I'm just throwing this out. Maybe something I'm not aware of yet.
Thanks
FF
--
You received this message because you are subscribed to the Google Groups
"sinatrarb" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "sinatrarb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sinatrarb+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
French Fry
2017-10-26 17:47:58 UTC
Permalink
Thank you for the reply Jason! I hadn't noticed it till this morning.
Last night I played with send_file and while it "works" I ran into two
problems. The first might be fixable , that being, the send_file helper
seems to take the header information from the file, and insert it into the
html audio component type option. I did trying hard coding it into the
helper options, but a) it didn't stick , while I tried using 'audio/mp3' ,
it reverts back to 'audio/mpeg'. Still it works like that but nothing I
could do with type audio/flac. Just keeps going into octet stream and I
get a download of the file.

The second issue which is, I think, a side effect of the way send_file
works is it just creates an html page with the player as the only component
in the body. I wanted the player as a partial , perhaps as a footer or
something. I haven't figured out if that is doable or not.

Lastly, I was playing around with some javascript to preview files (onclick
links, etc) but I think it still wouldn't work with the files outside of
public.
Post by Jason Rogers
The first argument to *send_file* can be an absolute or relative path. E.g.
get '/absolute' *do*
send_file *"*/absolute/path/to/pic.jpg*"*, disposition: *"*inline*"*
*end*
get '/relative' *do*
send_file *"*../../../relative/path/to/pic.jpg*"*, disposition: *"*
inline*"*
*end*
Does that help?
--
Jason Rogers
Post by French Fry
I want to be able to play audio files that are outside root. I've been
reading around and it looks like options are non-existent. Even if I set
additional public folders, the files span multiples directories (and
drives). I looked at Rack::TryStatic but it looks like I'd have to
downgrade Rack, from 2.x to 1.7. Doesn't sound like a good idea.
So I'm just throwing this out. Maybe something I'm not aware of yet.
Thanks
FF
--
You received this message because you are subscribed to the Google Groups
"sinatrarb" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "sinatrarb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sinatrarb+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
French Fry
2017-10-26 19:48:15 UTC
Permalink
Updating this post. I am now able to get any file type/extension into the
send file options. Now I just need to figure out how to get the delivered
inside a partial.
Post by French Fry
Thank you for the reply Jason! I hadn't noticed it till this morning.
Last night I played with send_file and while it "works" I ran into two
problems. The first might be fixable , that being, the send_file helper
seems to take the header information from the file, and insert it into the
html audio component type option. I did trying hard coding it into the
helper options, but a) it didn't stick , while I tried using 'audio/mp3' ,
it reverts back to 'audio/mpeg'. Still it works like that but nothing I
could do with type audio/flac. Just keeps going into octet stream and I
get a download of the file.
The second issue which is, I think, a side effect of the way send_file
works is it just creates an html page with the player as the only component
in the body. I wanted the player as a partial , perhaps as a footer or
something. I haven't figured out if that is doable or not.
Lastly, I was playing around with some javascript to preview files
(onclick links, etc) but I think it still wouldn't work with the files
outside of public.
Post by Jason Rogers
The first argument to *send_file* can be an absolute or relative path. E.g.
get '/absolute' *do*
send_file *"*/absolute/path/to/pic.jpg*"*, disposition: *"*inline*"*
*end*
get '/relative' *do*
send_file *"*../../../relative/path/to/pic.jpg*"*, disposition: *"*
inline*"*
*end*
Does that help?
--
Jason Rogers
Post by French Fry
I want to be able to play audio files that are outside root. I've been
reading around and it looks like options are non-existent. Even if I set
additional public folders, the files span multiples directories (and
drives). I looked at Rack::TryStatic but it looks like I'd have to
downgrade Rack, from 2.x to 1.7. Doesn't sound like a good idea.
So I'm just throwing this out. Maybe something I'm not aware of yet.
Thanks
FF
--
You received this message because you are subscribed to the Google
Groups "sinatrarb" group.
To unsubscribe from this group and stop receiving emails from it, send
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "sinatrarb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sinatrarb+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...