这是我从imgur回复:
{
"status" : 200,
"data" : {
"errorCode" : null,
"ticket" : "c4fb887c"
},
"success" : true
}
我如何创建请求?
let video = //here I have URL of video, for example: file:///private/var/mobile/Containers/Data/PluginKitPlugin/FAB4AFC7-56C6-4949-8938-31DCD65A13CB/tmp/trim.B31D7604-B991-4D89-AD61-18DE9D9FD7FD.MOV
let url = URL(string: "https://api.imgur.com/3/image")!
Alamofire.upload(multipartFormData: { multipart in
if let video = image.video {
let data = try! Data(contentsOf: video, options: .mappedIfSafe)
multipart.append(data, withName: "video", fileName: "video.mp4", mimeType: "video/mp4")
}
}, to: url, headers: headers, encodingCompletion: { result in
if case .success(let upload, _, _) = result {
upload.responseJSON { response in
let json = JSON(response.data)
print(json)
}
}
})
我期望什么?
指向视频的某些链接
所有您需要做的就是将您的网址替换为:
let url = URL(string: "https://api.imgur.com/3/upload")!
然后您将收到这样的响应:
{
"data" : {
"ad_url" : null,
"mp4" : "https:\/\/i.imgur.com\/GD86Stz.mp4",
"datetime" : 1590905085,
"in_gallery" : false,
"account_id" : null,
"title" : null,
"width" : 0,
"height" : 0,
"nsfw" : null,
"bandwidth" : 0,
"name" : "",
"is_ad" : false,
"size" : 0,
"description" : null,
"vote" : null,
"views" : 0,
"has_sound" : false,
"ad_type" : null,
"account_url" : null,
"in_most_viral" : false,
"link" : "https:\/\/i.imgur.com\/GD86Stz.mp4",
"processing" : {
"status" : "pending"
},
"deletehash" : "twCk1gbdjcp4FmH",
"favorite" : false,
"id" : "GD86Stz",
"section" : null,
"animated" : true,
"type" : "video\/mp4",
"tags" : [
],
"hls" : ""
},
"status" : 200,
"success" : true
}