Sample code for 30+ languages & platforms
Swift

Download a Jira Attachment

See more Jira Examples

Demonstrates how to download a Jira attachment to a file.

Chilkat Swift Downloads

Swift

func chilkatTest() {
    var success: Bool = false

    // 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"
    success = http.download(url: url, saveToPath: localFilePath)
    if success != true {
        print("\(http.lastErrorText!)")
        return
    }

    print("Successfully downloaded Jira attachment.")

}