better file info

master
nixo 2019-05-21 19:21:49 +02:00
parent 80e022fefb
commit f463e41447
1 changed files with 8 additions and 3 deletions

View File

@ -517,10 +517,13 @@ function giveconverted(file, bitrate, format)
iodata = convert(file, bitrate = bitrate, format = format)
headers = Dict{String,String}()
suffix = format
mime = suffix in keys(Mux.mimetypes) ? Mux.mimetypes[suffix] : suffix
mime = suffix in keys(Mux.mimetypes) ? Mux.mimetypes[suffix] :
"application/octet-stream"
headers["Content-Type"] = mime
# headers["Content-Length"] = string(length(data))
return Dict(:body => take!(iodata), :headers => headers)
return Dict(:body => take!(iodata),
:headers => headers,
:file => )
end
function convert(infile; bitrate = 64, format = "oga")
@ -562,10 +565,12 @@ function sendfile(path; suffix = nothing)
isfile(path) || return Dict{String,String}(:body => "Not Found")
suffix = suffix == nothing ? lowercase(split(path, '.')[end]) : suffix
headers = Dict{String,String}()
mime = suffix in keys(Mux.mimetypes) ? Mux.mimetypes[suffix] : suffix
mime = suffix in keys(Mux.mimetypes) ? Mux.mimetypes[suffix] :
"application/octet-stream"
headers["Content-Type"] = mime
headers["Content-Length"] = string(filesize(path))
return Dict(:body => read(path),
:file => filename(path),
:headers => headers)
end