【问题标题】:How do I restrict UIDocumentPicker from adding .sh executable files in iOS 14.0 swift?如何限制 UIDocumentPicker 在 iOS 14.0 swift 中添加 .sh 可执行文件?
【发布时间】:2021-08-03 16:37:38
【问题描述】:

目前使用[.plainText, .spreadsheet, .html, .pdf, .xml, .presentation, .jpeg, .bmp, .gif, .png, .tiff, .content]这些UTTypes但仍然可以附加.sh类型文件,我如何通过仍然支持文本和doc文件来限制可执行文件。

UTType 也没有指定 .doc、.docx 文件的类型

【问题讨论】:

    标签: swift uidocumentpicker


    【解决方案1】:

    我不确定你是否可以限制 .sh 文件类型,因为当你接受纯文本时它可能是允许的。关于 doc 文件类型,您可以扩展 UTTType 并实现自己的 .doc.docx 类型:

    import UniformTypeIdentifiers
    
    extension UTType {
    
        static let doc: Self = .init(filenameExtension: "doc")!
        static let docx: Self = .init(filenameExtension: "docx")!
    
        static let xls: Self = .init(filenameExtension: "xls")!
        static let xlsx: Self = .init(filenameExtension: "xlsx")!
    
        static let ppt: Self = .init(filenameExtension: "ppt")!
        static let pptx: Self = .init(filenameExtension: "pptx")!
    
    }
    

    UTType.doc   // com.microsoft.word.doc
    UTType.docx  // org.openxmlformats.wordprocessingml.document
    
    UTType.xls   // com.microsoft.excel.xls
    UTType.xlsx  // org.openxmlformats.spreadsheetml.sheet
    
    UTType.ppt   // com.microsoft.powerpoint.ppt
    UTType.pptx  // org.openxmlformats.presentationml.presentation
    

    【讨论】:

      猜你喜欢
      • 2014-12-17
      • 1970-01-01
      • 2012-10-22
      • 1970-01-01
      • 2020-04-12
      • 2020-01-24
      • 2019-11-17
      • 2019-09-10
      • 1970-01-01
      相关资源
      最近更新 更多