ios - Save PDF file to CloudKit -


i've been digging around trying find way save , fetch pdf file cloudkit.

what approach?

should save bytes or asset ?

after saving able fetch , present user in save form saved, file.pdf ?

i haven't seen trying save in format cloudkit.

i save images ckasset, should take same approach?

i have following check:

if attachmenturl.count > 0 {         var attachments: [ckasset] = []         attachmenturl.foreach { (url) in             print("url fetch\n")             {                 let data = try data(contentsof: url)                 guard let asset = createasset(from: data) else { return }                 attachments.append(asset)              } catch {                 print("error occured:", error)                 return             }         }         post["attachments"] = attachments ckrecordvalue     } 

the post["attachments"] of type asset list , array of ckasset

the createasset(:) function following:

fileprivate func createasset(from data: data) -> ckasset? {     var returnasset: ckasset? = nil     let tempstr = processinfo.processinfo.globallyuniquestring     let filename = "\(tempstr)_file.bin"     let baseurl = url(fileurlwithpath: nstemporarydirectory())     let fileurl = baseurl.appendingpathcomponent(filename, isdirectory: false)     {         try data.write(to: fileurl, options: [.atomicwrite])         returnasset = ckasset(fileurl: fileurl)     } catch {         print("error creating asset: \(error)")     }     return returnasset } 

i can save file cloudkit, i'm in doubt if can fetch pdf file type can images, since access them after fetching asset getting nsdata , instantiate image data uiimage(data: data)


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -