{"id":15037945,"url":"https://github.com/itenfay/cxdownload","last_synced_at":"2025-04-09T23:40:38.347Z","repository":{"id":56863400,"uuid":"252501974","full_name":"itenfay/CXDownload","owner":"itenfay","description":"Swift断点续传下载，支持Objective-C。包含大文件下载，后台下载，杀死进程，重新启动时继续下载，设置下载并发数，监听网络改变等。","archived":false,"fork":false,"pushed_at":"2024-04-23T14:46:20.000Z","size":7781,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2024-06-02T10:13:52.019Z","etag":null,"topics":["breakpoint-download","ios","objc","objcective-c","swift","swift4","swift5"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/itenfay.png","metadata":{"files":{"readme":"README-en.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-02T16:00:14.000Z","updated_at":"2024-06-02T10:13:59.385Z","dependencies_parsed_at":"2024-06-02T10:13:56.197Z","dependency_job_id":"dc7774a1-cdfe-4782-873f-f3dace1ff555","html_url":"https://github.com/itenfay/CXDownload","commit_stats":{"total_commits":11,"total_committers":3,"mean_commits":"3.6666666666666665","dds":0.2727272727272727,"last_synced_commit":"f5b77561a29675cf1fd92bdd613f2533a5bbd658"},"previous_names":["itenfay/cxdownload"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itenfay%2FCXDownload","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itenfay%2FCXDownload/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itenfay%2FCXDownload/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itenfay%2FCXDownload/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/itenfay","download_url":"https://codeload.github.com/itenfay/CXDownload/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248131466,"owners_count":21052819,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["breakpoint-download","ios","objc","objcective-c","swift","swift4","swift5"],"created_at":"2024-09-24T20:36:24.907Z","updated_at":"2025-04-09T23:40:38.316Z","avatar_url":"https://github.com/itenfay.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"[中文版](README.md) | **English Version**\n\n# CXDownload\n\nRealization of breakpoint transmission download with Swift, support Objective-C. Including large file download, background download, killing the process, continuing to download when restarting, setting the number of concurrent downloads, monitoring network changes and so on.\n\n[![Version](https://img.shields.io/cocoapods/v/CXDownload.svg?style=flat)](https://cocoapods.org/pods/CXDownload)\n[![License](https://img.shields.io/cocoapods/l/CXDownload.svg?style=flat)](https://cocoapods.org/pods/CXDownload)\n[![Platform](https://img.shields.io/cocoapods/p/CXDownload.svg?style=flat)](https://cocoapods.org/pods/CXDownload)\n\n## Preview\n\n\u003cdiv align=left\u003e\n\u0026emsp; \u003cimg src=\"https://github.com/itenfay/CXDownload/raw/master/IMG_0686.gif\" width=\"50%\" /\u003e\n\u003c/div\u003e\n\n\u003e **If you think it's okay, please give it a `star`**\n\n## Explanation\n\n- CXDownloadManager.swift: **The download task management**\n- CXDownloadTaskProcessor.swift: **The download task processor**\n- CXDownloadModel.swift: **The download model**\n- CXDownloadDatabaseManager.swift: **The download database management**\n- FileUtils.swift: **The file tool**\n- Logger.swift: **This outputs the log to the console**\n- String+Cx.swift: **This extends the `cx_md5`, `cxd_sha2` properties for `String`**\n- ...\n\n## Installation\n\n`CXDownload` is available through [CocoaPods](https://cocoapods.org). To install it, simply add the following line to your Podfile:\n\n```ruby\npod 'CXDownload'\n```\n\n## Usage\n\n\u003e Note: In order to better understand the usages, please check the project example.\n\n### Monitor download status and progress\n\n```\nfunc addNotification() {\n    NotificationCenter.default.addObserver(self, selector: #selector(downloadStateChange(_:)), name: CXDownloadConfig.stateChangeNotification, object: nil)\n    NotificationCenter.default.addObserver(self, selector: #selector(downloadProgressChange(_:)), name: CXDownloadConfig.progressNotification, object: nil)\n}\n\n@objc func downloadStateChange(_ noti: Notification) {\n    guard let downloadModel = noti.object as? CXDownloadModel else {\n        return\n    }\n    if downloadModel.state == .finish {\n        CXDLogger.log(message: \"filePath: \\(downloadModel.localPath ?? \"\")\", level: .info)\n    } else if downloadModel.state == .error || downloadModel.state == .cancelled {\n        if let stateInfo = downloadModel.stateInfo {\n            CXDLogger.log(message: \"error: \\(stateInfo.code), message: \\(stateInfo.message)\", level: .info)\n        }\n    }\n}\n\n@objc func downloadProgressChange(_ noti: Notification) {\n    guard let downloadModel = noti.object as? CXDownloadModel else {\n        return\n    }\n    CXDLogger.log(message: \"[\\(downloadModel.url)] \\(Int(downloadModel.progress * 100)) %\", level: .info)\n}\n```\n\n### Download\n\n- Default download directory and file name.\n\n```\nCXDownloadManager.shared.download(url: urls[0])\n```\n\n```\ndownloadButton1.dl.download(url: urls[0])\n```\n\n- Custom download directory and file name.\n\n```\nCXDownloadManager.shared.download(url: urls[1], toDirectory: \"Softwares\", fileName: \"MacDict_v1.20.30.dmg\")\n```\n\n```\ndownloadButton2.dl.download(url: urls[1], toDirectory: \"Softwares\", fileName: \"MacDict_v1.20.30.dmg\") \n```\n\n### Pause\n\n```\nCXDownloadManager.shared.pause(url: urls[0])\n```\n\n```\npauseButton1.dl.pauseTask(url: urls[0])\n```\n\n### Cancel\n\n```\nCXDownloadManager.shared.cancel(url: urls[0])\n```\n\n```\ncancelButton1.dl.cancelTask(url: urls[0])\n```\n\n### Delete target file\n\n```\nCXDownloadManager.shared.deleteTaskAndCache(url: urls[0])\ndeleteButton1.dl.deleteTaskAndCache(url: urls[0])\n```\n\n```\nCXDownloadManager.shared.deleteTaskAndCache(url: urls[1], atDirectory: \"Softwares\", fileName: \"MacDict_v1.20.30.dmg\")\ndeleteButton2.dl.deleteTaskAndCache(url: urls[1], atDirectory: \"Softwares\", fileName: \"MacDict_v1.20.30.dmg\")\n```\n\n## Recommendation\n\n- [FireKylin](https://github.com/itenfay/FireKylin) - `FireKylin` provides many utilities and rich extensions of Swift language.\n- [MarsUIKit](https://github.com/itenfay/MarsUIKit) - `MarsUIKit` wraps some commonly used UI components.\n- [RxListDataSource](https://github.com/itenfay/RxListDataSource) - `RxListDataSource` provides data sources for UITableView or UICollectionView.\n- [CXNetwork-Moya](https://github.com/itenfay/CXNetwork-Moya) - `CXNetwork-Moya` encapsulates a network request library with Moya and ObjectMapper.\n\n## Example\n\nTo run the example project, clone the repo, and run `pod install` from the Example directory first.\n\n## License\n\n`CXDownload` is available under the MIT license. See the LICENSE file for more info.\n\n## Feedback is welcome\n\nIf you notice any issue to create an issue. I will be happy to help you.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitenfay%2Fcxdownload","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fitenfay%2Fcxdownload","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitenfay%2Fcxdownload/lists"}