Search code examples
iosswiftdomdocumenticloudicloud-drive

How to show particular file format from iclouds derive in ios swift


In my application upload the file from iclouds derive. want to upload xlsx, docx, txt.

want to upload the xlsx file means from iclouds derive want to display only xlsx another files should not display.[docx,txt]

same if the user want to display docx file means xlsx and txt ,xlsx file should not be display.

Here my code

 @IBAction func moveiclouds_BtnClick(_ sender: Any) {
        let documentPicker = UIDocumentPickerViewController(documentTypes: [kUTTypePDF as String, "com.microsoft.word.doc", "com.microsoft.excel.xls", kUTTypeCompositeContent as String, kUTTypeJPEG as String], in: .import)
        documentPicker.delegate = self
        self.present(documentPicker, animated: true, completion: nil)
    }


extension CreateFeesView: UIDocumentPickerDelegate{
    func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentAt url: URL) {
        let cico = url as URL
        cico_files = cico
        filepath_fees = url.pathExtension
    }
}

enter image description here

from iclouds derive all files are diplaying in recently added list. want to display only particular file in the list. how to achive help me. Thank advance


Solution

  • Just adjust the documentTypes: argument when creating your document picker.

    documentTypes: ["org.openxmlformats.wordprocessingml.document"]

    will let the user only select docx files.

    documentTypes: ["org.openxmlformats.spreadsheetml.sheet"]

    will let the user only select xlsx files.