Reputation: 2808
We are serving static files from a build process where the output files are to be served as application/octet-stream. The problem is that the files extensions are related to their version, so I need:
.000 application/octet-stream .001 application/octet-stream ... .100 application/octet-stram ...
Is there a way in IIS7 to add a pattern of extensions or some other way so I don't have to manually type in 100+ new entries?
Upvotes: 0
Views: 1364
Reputation: 64700
No, there is really no way to specify a regex or pattern for that. I'd suggest scripting it from the command line. See this for the syntax, but for a single mime type something like this should work:
appcmd set config /section:staticContent /+"[fileExtension=' .000 ', mimeType='application/octet-stream ']"
So to do it for 100 of them, try this in a windows cmd file:
@echo off
FOR /L %%G IN (0,1,100) DO (call :addfile %%G)
:addfile
if %1 LSS 10 (
(call :updateconfig 00%1)
) else (
if %1 LSS 100 (
(call :updateconfig 0%1)
) else (
(call :updateconfig %1)
)
)
goto :EOF
:updateconfig
appcmd set config /section:staticContent /+"[fileExtension=' .%1 ', mimeType='application/octet-stream ']"
goto :EOF
Upvotes: 1
Reputation: 7074
You can add them programatically by reading the extensions from a file or what have you.
A good example of how to do this you cand find here.
Upvotes: 1