- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我希望能够在 PowerShell 中复制此 adsutil.vbs 行为:
cscript adsutil.vbs set W3SVC/$(ProjectWebSiteIdentifier)/MimeMap
".pdf,application/pdf"
$website = gwmi -namespace "root\MicrosoftIISv2" -class "IISWebServerSetting"
-filter "ServerComment like '%$name%'"
if (!($website -eq $NULL)) {
#add some mimetype
}
([adsi]"IIS://localhost/MimeMap").MimeMap
最佳答案
好吧,经过多次挫折和研究,这就是我想出的解决方案......
a) 获取 COM DLL "Interop.IISOle.dll"并将其放在易于引用的位置
(例如,在虚拟项目中引用 COM 组件“Active DS IIS Namespace Provider”,构建并从 bin 文件夹中获取 DLL)
b)
function AddMimeType ([string] $websiteId, [string] $extension,
[string] $application)
{
[Reflection.Assembly]::LoadFile("yourpath\Interop.IISOle.dll") | Out-Null;
$directoryEntry = New-Object System
.DirectoryServices
.DirectoryEntry("IIS://localhost/W3SVC/$websiteId/root");
try {
$mimeMap = $directoryEntry.Properties["MimeMap"]
$mimeType = New-Object "IISOle.MimeMapClass";
$mimeType.Extension = $extension
$mimeType.MimeType = $application
$mimeMap.Add($mimeType)
$directoryEntry.CommitChanges()
}
finally {
if ($directoryEntry -ne $null) {
if ($directoryEntry.psbase -eq $null) {
$directoryEntry.Dispose()
} else {
$directoryEntry.psbase.Dispose()
}
}
}
}
AddMimeType "123456" ".pdf" "application/pdf"
关于powershell - 如何使用 POWERSHELL 在 IIS6 网站中设置 MimeTypes?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2957994/
我正在使用 MediaRecorder API 在页面上录制一些媒体。在我的 MediaRecorder 初始化中,我没有指定内容类型,因为我不需要任何特别的内容。浏览器可以选择它想要的内容。 var
我有一个可以返回 text/html 或 application/pdf 内容的 servlet。显然,看起来 Internet Explorer (IE7) 没有正确处理应用程序/pdf。 例如。
我正在使用 C# 库 DotNetZip(Ionic.Zip 和 Ionic.Zlib)从目录生成电子书。目录如下所示: BookName | |___content/ | images/
我有一个带有二进制字段的文件模型 class File(models.Model): id = models.AutoField(primary_key=True) file = mo
覆盖模型保存方法时,有没有办法获取上传文件的内容类型?我试过这个: def save(self): print(self.file.content_type) super(Media,
我正在从 azure 读取文件。 mimetype 是 video/mp4 ,位于 response.headers["content-type"] 中。我找不到如何向文件添加 mimetypes,因
我想知道如果我运行这段代码会发生什么: MimeType Tester 我的内容将被解析为 XML 或 HTML?两个都?其他? 我还有一个 JS
我怎样才能从应用程序中获取 mimeType。 我正在开发一个基于 mimeType 过滤某些已安装应用程序的应用程序。 有人可以帮我解决这个问题吗? 非常感谢 最佳答案 mime 类型与 Activ
我需要获取项目对象的 MimeType: 我有什么:- 来自 EWS 的项目对象 (microsoft.exchange.webservices.data.Item) 我想要什么:- 该项目的 mim
我下载了一些文件,比如word、ppt、excel。但我不知道他们的 MIMETYPE 和后缀。有什么方法可以获取这些文件的 MIMETYPE? 最佳答案 如果您不知道后缀,则必须查看文件内容。通常,
如何使用 mimetypes 包中的 add_type() 函数添加新的 mimetype?我需要对 python 文件系统做些什么吗?如果我尝试类似这样的操作:add_type('text/new'
有人知道一种从字节数组中获取 mime 类型的方法吗?注意,我想在没有外部库的情况下做到这一点,只有 native java。 最佳答案 有一种方法可以使用 Java 7 来做到这一点,但它有点笨拙(
这只是一个用户上传一个文件。 最佳答案 UploadedFile.content_type 将返回上传时随文件一起发送的内容类型 header 。 如果您还需要在保存后检查文件,您可以使用 pytho
我正在尝试使用 Intent 打开一个 File,但 Android 没有打开适合该文件类型的应用程序。 使用以下代码,每个文件 - pdf、图像,所有内容 - 都使用音乐应用程序打开: Intent
从文件中使用 finfo 获取 mimetype $finfo = new finfo(FILEINFO_MIME); $type = $finfo->file($file); 从字符串中使用 fin
MIME::Types.type_for(filename) 我需要安装什么 gem,使用它需要什么文件? 最佳答案 gem install mime-types 和require 'mime/typ
我有两个节点应用程序在两个不同的端口上运行。 为了让 nginx 适本地路由请求,我有两个位置 block , # /etc/nginx/sites-available/my_site.com ser
如何在 xcode 中将 mimetype 转换为文件扩展名 例如我有这个代码 File Extension MIME Type aifc audio/x-aif
我正在考虑使用浏览器的 navigator.mimeTypes 数组作为第三级用户/浏览器标识符。例如,当我在 Chrome 上运行时... console.log(navigator.mimeTyp
我正在通过 MimeType 扫描目录。到目前为止,我的代码计算了目录中现有 MimiType 的总数: File dir = new File(dirPath); File[] files = di
我是一名优秀的程序员,十分优秀!