视频上传到Swift中的Amazon S3

视频上传到Swift中的Amazon S3,第1张

概述我已尝试在 Swift中将视频文件上传到Amazon S3,但我失败了.这是我的代码.我希望你能引导我. @IBAction func uploadVideoBtnClicked(sender: AnyObject){ //-- Add Amazon Video upload code var uploadRequest: AWSS3TransferManagerUploadR 我已尝试在 Swift中将视频文件上传到Amazon S3,但我失败了.这是我的代码.我希望你能引导我.

@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中传递视频的URL

func 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所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1002462.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存