I am tryin to upload a video to Cloudinary (unsigned upload) using Swift 3, from a video url that I know for sure is there. I am trying to take the content of the local URL and turn it into Data, and then upload the data. I get a message:
Error Domain=com.cloudinary.error Code=400 "(null)" UserInfo={message=Invalid image file}
This is my code for uploading:
func approveFunc(){
let config = CLDConfiguration(cloudName: "xxxxx", apiKey: "xxxxxx")
let cloudinary = CLDCloudinary(configuration: config)
let params = CLDUploadRequestParams(params: ["resource_type": "video" as AnyObject])
var data: Data?
do{
data = try NSData(contentsOfFile: (self.videoURL.relativePath), options: NSData.ReadingOptions.alwaysMapped) as Data
} catch {
}
cloudinary.createUploader().upload(data: data!, uploadPreset: "fycdpm" , params: params, progress: nil, completionHandler: {(response, error) in
print("done")
print(response)
print(error)
})
}
I also tried uploading directly from the file url:
cloudinary.createUploader().upload(url: self.videoURL, uploadPreset: "fycdp7cm" , params: params, progress: nil, completionHandler: {(response, error) in
print("done")
print(response)
print(error)
})
And got the same error