@IBAction func uploadVIDeoBtnClicked(sender: AnyObject){ //-- Add Amazon VIDeo upload code var uploadRequest: awss3transfermanagerUploadRequest = awss3transfermanagerUploadRequest() uploadRequest.bucket = "appfile" uploadRequest.key = "foldername/test.mov" //Move vIDeo file to the application folder so it can be read var savedVIDeoURLToBeUsed = NSUserDefaults.standardUserDefaults().objectForKey("ThisIsTheVIDeoIWantToUse") as! String print("VIDeo saved in Store: \(savedVIDeoURLToBeUsed)") var url: NSURL = self.vIDeoPath uploadRequest.body = url print("URL: \(url)") let transferManager: awss3transfermanager = awss3transfermanager.defaultS3TransferManager() transferManager.upload(uploadRequest).continueWithExecutor(AWSExecutor.mainThreadExecutor(),withBlock: { (AWSTask) -> AnyObject! in //Handle errors if AWSTask.error != nil { println("Error in uploading the vIDeo: \(AWSTask.error)") // Retrive information important for later downloading } else { println("VIDeo upload successful..") var uploadResult: AnyObject! = AWSTask.result println("Upload result: \(uploadResult)") } return nil })}
我在现有项目中添加了pod库文件.
解决方法 在uploadVIDeo中传递视频的URLfunc uploadVIDeo(fileUrl : URL){ let newKey = "vIDeo/1.mov" let uploadRequest = awss3transfermanagerUploadRequest() uploadRequest?.body = fileUrl as URL uploadRequest?.key = newKey uploadRequest?.bucket = "YourBucketname" uploadRequest?.acl = AWSS3ObjectCannedACL.publicRead uploadRequest?.ContentType = "movIE/mov" uploadRequest?.uploadProgress = { (bytesSent,totalBytesSent,totalBytesExpectedToSend) -> VoID in dispatchQueue.main.async(execute: { let amountUploaded = totalBytesSent // To show the updating data status in label. print(amountUploaded) }) } let transferManager = awss3transfermanager.default() transferManager.upload(uploadRequest!).continueWith(executor: AWSExecutor.mainThread(),block: { (task) in if task.error != nil { print(task.error.deBUGDescription) } else { // Do something with your result. print("done") } return nil })}总结
以上是内存溢出为你收集整理的视频上传到Swift中的Amazon S3全部内容,希望文章能够帮你解决视频上传到Swift中的Amazon S3所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)