gpt4 book ai didi

ios - 如何在后台将视频文件上传到AWS?

转载 作者:行者123 更新时间:2023-11-30 11:08:52 29 4
gpt4 key购买 nike

我对在后台上传视频(例如 swift 中的应用程序)有疑问。我们应该使用背景标识符还是任何想法?

最佳答案

为此使用 alamofire。对于 Almofire,请阅读 Tutorial

视频将作为数据流发送。使用此函数将视频转换为数据然后发送到服务器。

//This function will send the stream of data to server.

let videoData = Data() //you need proper video data here.
let url = URL.init(string: "URL to upload") //place your valid url here.

Alamofire.upload( multipartFormData: { multipartFormData in
multipartFormData.append(videoData, withName: "video", fileName: "video.mp4", mimeType: "video/mp4")

}, to: url!, encodingCompletion: { encodingResult in
switch encodingResult {
case .success(let upload, _, _):
upload.responseJSON { response in
if let JSON = response.result.value {
print("SUCCESS\n\n", JSON)
} else {
print("FAILED\n\n", response)
}
}
case .failure(let encodingError):
print(encodingError)
}
})

关于ios - 如何在后台将视频文件上传到AWS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52399337/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com