Files
real-e-party-iOS/YuMi/E-P/Common/EPQCloudConfig.swift.backup
2025-10-17 14:52:29 +08:00

57 lines
1.7 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// 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)
}
}