// // EPQCloudConfig.swift // YuMi // // Created by AI on 2025-10-11. // import Foundation /// QCloud 配置数据模型(对应 UploadFileModel) struct EPQCloudConfig { let secretId: String let secretKey: String let sessionToken: String let bucket: String let region: String let customDomain: String let startTime: Int64 let expireTime: Int64 let appId: String let accelerate: Int /// 从 API 返回的 dictionary 初始化 /// API: GET tencent/cos/getToken init?(dictionary: [String: Any]) { // 必填字段检查 guard let secretId = dictionary["secretId"] as? String, let secretKey = dictionary["secretKey"] as? String, let sessionToken = dictionary["sessionToken"] as? String, let bucket = dictionary["bucket"] as? String, let region = dictionary["region"] as? String, let customDomain = dictionary["customDomain"] as? String, let appId = dictionary["appId"] as? String else { return nil } self.secretId = secretId self.secretKey = secretKey self.sessionToken = sessionToken self.bucket = bucket self.region = region self.customDomain = customDomain self.appId = appId // 可选字段使用默认值 self.startTime = (dictionary["startTime"] as? Int64) ?? 0 self.expireTime = (dictionary["expireTime"] as? Int64) ?? 0 self.accelerate = (dictionary["accelerate"] as? Int) ?? 0 } /// 检查配置是否过期 var isExpired: Bool { return Date().timeIntervalSince1970 > Double(expireTime) } }