2

user upload file and its kept in file directory without file extensions

so it looks like file/ID

what i had done, when user download any file, we have created a rewrite rule for the same which looks like

rewrite ^/file/(.+?)/(.*)$ /file/$1;

http://example.com/file/id/name.mp4 -> http://example.com/file/id

now, the problem i face is nginx is giving content-type (mime) a application/octet-stream

Which is not the actual mime type of file, this is because default mime type is application/octet-stream

i also know we can change the same using nginx configuration,

But my question is that can we set mime-type base on the url file extension

2
  • 1
    But you got rid of the file extension! Try keeping it. Feb 21, 2014 at 21:08
  • I have a somewhat related issue: serverfault.com/questions/889301/… and I suspect the answer to both our question is "it's not possible", if nginx doesn't indeed use something like MIME magic to determine file types, instead of just relying on filename endings. If it uses filename endings (extensions) only, then we may be SOL...
    – Rouben
    Dec 22, 2017 at 5:08

0

You must log in to answer this question.

Browse other questions tagged .