Created
March 23, 2017 14:04
-
-
Save venkatchm/1fd321f2c1c4f0491b4bbb709c3baa8f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func transformedVideoURL(_ publicID: String?) -> URL? { | |
let transformation = CLTransformation() | |
transformation?.width = Float(960) | |
transformation?.height = Float(540) | |
transformation?.crop = "pad" | |
guard let _transformation = transformation, let _publicID = publicID else { | |
return nil | |
} | |
let options = ["type": "authenticated", | |
"sign_url": "YES", | |
"resource_type": "video", | |
"secure": true, | |
"transformation": _transformation] as [String : Any] | |
do { | |
let cloudinary = try CLCloudinary(url: Configuration.cloudinaryURL()) | |
guard let convertedURL = cloudinary?.url(_publicID, options: options) else { | |
return nil | |
} | |
return URL(string: convertedURL) | |
} catch { | |
return nil | |
} | |
} | |
let videoURL = transformedVideoURL("B03D4E5B06AB63FA8375FF00000B3273/B43D4E5B06AB63FA8375FF00000B3273/pyskfy03rzaz0u0o9469") | |
print(videoURL) | |
//https://res.cloudinary.com/cloudname/video/authenticated/s--8jiINiDJ--/c_pad,h_540,w_960/v1/B03D4E5B06AB63FA8375FF00000B3273/B43D4E5B06AB63FA8375FF00000B3273/pyskfy03rzaz0u0o9469 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment