2017-04-26 2 views
0

무비 파일을 만들었으며 로컬로 장치에 저장할 수 있습니다. 그러나 icloud 문서를 활용하여 icloud에 저장하고 공개적으로 공유하고 싶습니다. 어떻게 신속하게 이것을 사용합니까?AVCaptureMovieFileOutput을 iCloud에 저장하는 방법

일반 파일 저장을위한이 링크를 찾았습니다. Save iOS 8 Documents to iCloud Drive. 방법론은 장치에 로컬로 먼저 저장 한 다음 클라우드 드라이브에 저장하는 방법이라고 추측합니다. 하지만 아무도 이것에 대한 샘플을 가지고 있습니까? 예를 들어 아래에 UIDocument 함수를 구현할 수있는 기능은 무엇입니까?

override func contents(forType typeName: String) throws -> Any { 

} 

override func load(fromContents contents: Any, ofType typeName: String?) throws { 

} 

답변

0

불행히도, iCloud 드라이브로 "공유"하는 것은 불가능합니다. 보관 용 계정을 사용하십시오. 여기에 파일을 저장하는 코드가 있습니다. 먼저 DropboxClientsManager.authorizedClient 변수를 설정해야합니다. 물론, 개발자 페이지를 체크 아웃해야합니다. Corepath는 파일 경로입니다.

let client = DropboxClientsManager.authorizedClient! 
client.files.upload(path: corePath, mode: .overwrite, autorename: false, input: textData).response { response, error in 

    if let metadata = response { 
      // Get file (or folder) metadata 
     } 
     if let error = error { 
      switch error { 
      case .routeError(let boxed, let requestId): 
       switch boxed.unboxed { 
       case .path(let failedPath): 
         //rint("Failed update 2 path: \(failedPath)") 

         NotificationCenter.default.post(name: Notification.Name("dbFileCreationError"), object: nil, userInfo: nil) 
         break 

        default: 
         ////rint("Unknown \(error)") 
         break 
        } 
      case .internalServerError(let code, let message, let requestId): 
       ////rint("InternalServerError[\(requestId)]: \(code): \(message)") 
       NotificationCenter.default.post(name: Notification.Name("dbInternalServerError"), object: nil, userInfo: nil) 
       break 
      case .badInputError(let message, let requestId): 
       ////rint("BadInputError[\(requestId)]: \(message)") 
       NotificationCenter.default.post(name: Notification.Name("dbBadInputError"), object: nil, userInfo: nil) 
       break 
      case .authError(let authError, let requestId): 
       ////rint("AuthError[\(requestId)]: \(authError)") 
       NotificationCenter.default.post(name: Notification.Name("dbAuthError"), object: nil, userInfo: nil) 
       break 
      case .rateLimitError(let rateLimitError, let requestId): 
       ////rint("RateLimitError[\(requestId)]: \(rateLimitError)") 
       NotificationCenter.default.post(name: Notification.Name("dbRateLimitError"), object: nil, userInfo: nil) 
       break 
      case .httpError(let code, let message, let requestId): 
       ////rint("HTTPError[\(requestId)]: \(code): \(message)") 
       NotificationCenter.default.post(name: Notification.Name("dbHTTPError"), object: nil, userInfo: nil) 
       break 
      default: 
       break 
       } 
     } 
    } 
} 
+0

당신이 iCloud에 물건을 공유하는 것은 불가능 이유에 대해 자세히 설명 할 수 있습니까? –

+0

David, 클라우드 드라이브는 문서를 공유하는 API를 제공하지 않습니다. 사용하는 자산은 cloudKit을 통해 공유 할 수 있지만 전용 app를 통해 다른 appleID 사용자와 공유하게됩니다. 또한 두 번째 답변에서 코드를 게시 할 수있는 활동 앱을 통해 항목을 공유 할 수도 있습니다. – user3069232

+0

사과 부분에는 매우 이상합니다. 내가 제안한 것처럼 Dropbox를 사용하면 비디오 파일을 공유 할 수 있습니까? 요금이 부과 되나요? 아니면 단순히 사용자의 현재 할당 된 디스크 공간을 차지합니까? 다른 말로하면 현재 무료 또는 유료로 제공되는 서비스가 무엇이든간에 –

0

활동 앱을 통한 생각은 아니지만 공유 할 수도 있습니다. 기본 코드는 여기에서 볼 수 있습니다.

@IBAction func shareButtonClicked(sender: UIButton) { 
let textToShare = "Swift is awesome! Check out this website about it!" 

if let myWebsite = NSURL(string: "http://www.codingexplorer.com/") { 
    let objectsToShare = [textToShare, myWebsite] 
    let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil) 

    activityVC.popoverPresentationController?.sourceView = sender 
    self.presentViewController(activityVC, animated: true, completion: nil) 
} 
} 

자세한 내용은이 웹 페이지에서 설명합니다.

http://www.codingexplorer.com/sharing-swift-app-uiactivityviewcontroller/