iOS開源:SRDownloadManager-文件下載管理

FilomenaOGZ 7年前發布 | 8K 次閱讀 開源 iOS開發 移動開發

SRDownloadManager

Features

  • Provide download status callback, download progress callback, download complete callback.
  • Support multi-task at the same time to download.
  • Support breakpoint download even exit the App.
  • Support to delete the specified file by URL and clear all files that have been downloaded.
  • Support customize the directory where the downloaded files are saved.
  • 提供下載狀態回調, 下載進度回調, 下載完成回調.
  • 支持多任務同時下載.
  • 支持斷點下載, 即使退出重啟 App.
  • 支持通過 URL 刪除指定文件和清除所有已下載的文件.
  • 支持自定義保存下載文件的目錄.

Show

Installation

Drag the SRDownloadManager folder to the project.

Usage

[[SRDownloadManager sharedManager] downloadFile:fileURL state:^(SRDownloadState state) {
    // Called when download state changed.
} progress:^(NSInteger receivedSize, NSInteger expectedSize, CGFloat progress) {
    // Called when download receive data every time.
} completion:^(BOOL isSuccess, NSString *filePath, NSError *error) {
    // Called when download finished with success or error.
}];

APIs

/*
 The directory where the downloaded files are saved, default is .../Library/Caches/SRDownloadManager if not setted.
 /
@property (nonatomic, copy) NSString *downloadedFilesDirectory;

  • (instancetype)sharedManager;

  • (void)downloadFile:(NSURL *)URL

             state:(void (^)(SRDownloadState state))state
          progress:(void (^)(NSInteger receivedSize, NSInteger expectedSize, CGFloat progress))progress
        completion:(void (^)(BOOL isSuccess, NSString *filePath, NSError *error))completion;
  • (BOOL)isDownloadFileCompleted:(NSURL *)URL;

  • (NSString )fileFullPath:(NSURL )URL;

  • (CGFloat)fileDownloadedProgress:(NSURL *)URL;

  • (void)deleteFile:(NSURL *)URL;

  • (void)deleteAllFiles;

  • (void)suspendDownloadURL:(NSURL *)URL;

  • (void)suspendAllDownloads;

  • (void)resumeDownloadURL:(NSURL *)URL;

  • (void)resumeAllDownloads;

  • (void)cancelDownloadURL:(NSURL *)URL;

  • (void)cancelAllDownloads;</code></pre>

    If you have any question, submit an issue or contact me.

    If this repo helps you, please give it a star.

    Have Fun.

     

     

     

 本文由用戶 FilomenaOGZ 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!