文件下载
核心类
类名 | 类描述 |
---|---|
VHFileDownloadObject | 文件下载类 |
VHFileDownloadObject 关键方法
方法 | 方法描述 |
---|---|
getFileDownLoadWithWebinarId | 文件列表 |
getCheckDownloadWithWebinarId | 获取文件下载地址 |
VHFileDownloadObjectDelegate 代理方法
方法 | 方法描述 |
---|---|
uploadFileDownLoadWithModel | 更新文件下载列表 |
文件列表
- (void)getFileDownLoadWithWebinarId:(NSString *)webinarId menu_id:(NSString *)menu_id complete:(void (^)(NSDictionary * config, NSArray <VHFileDownloadListModel *> *file_download_list, NSError *error))complete;
参数名称 | 是否必须 | 示例 | 备注 |
---|---|---|---|
webinarId | 是 | 123456 | 活动 id |
menu_id | 是 | 123456 | 文件列表菜单 id |
complete | 返回数据 | file_download_list:列表数据 error:错误详情 |
VHFileDownloadListModel 参数详解
参数名称 | 备注 |
---|---|
file_name | 文件名称 |
file_size | 文件大小 |
file_ext | 文件类型 |
file_id | 文件 id |
file_type | 文件类型 |
file_desc | 文件简介 |
img_url | 文件 icon 图片 |
__weak __typeof(self)weakSelf = self;
[self.fileDownload getFileDownLoadWithWebinarId:webinar_id menu_id:file_download_menu_id complete:^(NSDictionary *config, NSArray<VHFileDownloadListModel *> *file_download_list, NSError *error) {
[weakSelf.dataSource removeAllObjects];
if (file_download_list) {
[weakSelf.dataSource addObjectsFromArray:file_download_list];
[weakSelf.tableView reloadData];
}
if (error) {
[VHProgressHud showToast:[NSString stringWithFormat:@"%@",error.localizedDescription]];
}
[weakSelf.tableView.mj_header endRefreshing];
}];
获取文件下载地址
- (void)getCheckDownloadWithWebinarId:(NSString *)webinarId menu_id:(NSString *)menu_id file_id:(NSString *)file_id complete:(void (^)(NSString * download_url, NSError *error))complete;
参数名称 | 是否必须 | 示例 | 备注 |
---|---|---|---|
webinarId | 是 | 123456 | 活动 id |
menu_id | 是 | 123456 | 文件列表菜单 id |
file_id | 是 | 123 | 文件 id |
complete | 返回数据 | download_url:下载地址 error:错误详情 |
[self.fileDownload getCheckDownloadWithWebinarId:self.webinar_id menu_id:self.file_download_menu_id file_id:fileDownloadListModel.file_id complete:^(NSString *download_url, NSError *error) {
if (download_url) {
NSURL * url = [NSURL URLWithString:download_url];
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) {
VHLog(@"%@",success ? @"完成下载" : @"错误");
}];
}
if (error) {
[VHProgressHud showToast:[NSString stringWithFormat:@"%@",error.localizedDescription]];
}
}];
更新文件下载列表
- (void)uploadFileDownLoadWithModel:(VHFileDownLoadUploadModel *)model;
VHFileDownLoadUploadModel 参数详解
参数名称 | 备注 |
---|---|
status | 是否显示 1 显示 0 不显示 |
webinar_id | 活动 id |
user_id | 用户 id |
type | 类型 |
menu_id | 菜单 id |
name | 名称 |
url | url |
#pragma mark 更新文件下载列表
- (void)uploadFileDownLoadWithModel:(VHFileDownLoadUploadModel *)model {
// 可以在这里调用列表接口刷一下
}
修改于 2025-05-27 11:59:31