(Swift) Download a Jira Attachment
Demonstrates how to download a Jira attachment to a file.
func chilkatTest() {
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let http = CkoHttp()!
http.followRedirects = true
// Provide the username/password for authentication
http.login = "jira@example.com"
http.password = "JIRA_API_TOKEN"
// The URL for a Jira attachment has this format:
// https://your-domain.atlassian.net/secure/attachment/{attachment_id}/{attachment_filename}
var url: String? = "https://chilkat.atlassian.net/secure/attachment/10001/starfish.jpg"
var localFilePath: String? = "qa_output/starfish.jpg"
var success: Bool = http.download(url, saveToPath: localFilePath)
if success != true {
print("\(http.lastErrorText!)")
return
}
print("Successfully downloaded Jira attachment.")
}
|