Iphone iOS上的文件关联-从Safari打开纯文本文件

Iphone iOS上的文件关联-从Safari打开纯文本文件,iphone,ios,ipad,safari,file-association,Iphone,Ios,Ipad,Safari,File Association,我想将基于文本的自定义文件类型与iOS上的应用程序相关联 当我打开指向某个php脚本后面的文件的链接时,Safari会显示“open in”选项,其中包含我的应用程序,这是可以的 但是,当我打开一个直接指向我的文件的链接(为了测试目的运行web服务器)时,Safari决定它可以读取文件本身并显示内容。这绝对不行 另一方面,如果我替换任何二进制文件(zip,…)并使用扩展名,文件关联仍然有效 plist info中的代码: <key>CFBundleDocumentTypes</

我想将基于文本的自定义文件类型与iOS上的应用程序相关联

当我打开指向某个php脚本后面的文件的链接时,Safari会显示“open in”选项,其中包含我的应用程序,这是可以的

但是,当我打开一个直接指向我的文件的链接(为了测试目的运行web服务器)时,Safari决定它可以读取文件本身并显示内容。这绝对不行

另一方面,如果我替换任何二进制文件(zip,…)并使用扩展名,文件关联仍然有效

plist info中的代码:

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeIconFiles</key>
        <array>
            <string>320.png</string>
            <string>64.png</string>
        </array>
        <key>CFBundleTypeName</key>
        <string>My File</string>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>LSHandlerRank</key>
        <string>Owner</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>com.Company.Product.ext</string>
        </array>
    </dict>
</array>
<key>UTExportedTypeDeclarations</key>
<array>
    <dict>
        <key>UTTypeConformsTo</key>
        <array>
            <string>public.data</string>
            <string>public.content</string>
            <string>public.text</string>
            <string>public.plain-text</string>
            <string>public.utf16-plain-text</string>
            <string>public.utf16-external-plain-text</string>
            <string>public.utf8-plain-text</string>
        </array>
        <key>UTTypeDescription</key>
        <string>My File</string>
        <key>UTTypeIdentifier</key>
        <string>com.Company.Product.ext</string>
        <key>UTTypeTagSpecification</key>
        <dict>
            <key>public.filename-extension</key>
            <string>ext</string>
            <key>public.mime-type</key>
            <string>application/octet-stream</string>
        </dict>
    </dict>
</array>
CbundleDocumentTypes
CbundleTypeConfigiles
320.png
64.png
CbundleTypeName
我的档案
CbundleTypeRole
观众
伊斯汉德兰克
所有者
lsItemContentType
com.Company.Product.ext
UTExportedTypeDeclarations
Uttypecommisto
公共数据
公共内容
public.text
公共文本
public.utf16-纯文本
public.utf16-external-plain-text
public.utf8-纯文本
UTTypeDescription
我的档案
UTTypeIdentifier
com.Company.Product.ext
Uttypetag规范
public.filename-extension
提取
public.mime-type
应用程序/八位字节流

我的问题是:如何说服Safari不要打开文件本身?有可能吗?我是否必须使用“应用程序/八位字节流”以外的mime类型?

为您的文件定义自定义mime类型(即
application/x-my.custom.type
),并让PHP或web服务器为其提供服务。这应该会有所帮助。

为您的文件定义自定义MIME类型(即
应用程序/x-my.custom.type
),并让PHP或web服务器为其提供服务。这应该会有帮助。

这对我也很有用。我还发现,在导出的类型UTI中设置文件扩展名既必要又充分,而设置MIME类型两者都不是。这对我来说也很有效。我还发现,在导出的类型UTI中设置文件扩展名既必要又充分,而设置MIME类型则两者都不必要。