55 lines
1.8 KiB
Swift
55 lines
1.8 KiB
Swift
//
|
|
// CommentImageModel.swift
|
|
// Crush
|
|
//
|
|
// Created by Leon on 2025/7/21.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
class CommentImageModel {
|
|
var uploadUrl: String?
|
|
var image: UIImage?
|
|
var isReport: Bool = false
|
|
var isCoach: Bool = false
|
|
var imageUploadComplete: ((Bool, UploadPhotoM) -> Void)?
|
|
|
|
@discardableResult
|
|
func startUpload(with image: UIImage, checkImage: Bool = false) -> UploadPhotoM {
|
|
self.image = image
|
|
|
|
if isReport {
|
|
let model = UploadPhotoM()
|
|
model.image = image
|
|
model.imageSize = image.pixelSize
|
|
model.isAutoCheckImage = checkImage
|
|
// Unknown: [NSDate date] timestamp implementation
|
|
model.addThisItemTimeStamp = Int(Date().timeIntervalSince1970) // Placeholder for timestamp
|
|
|
|
CloudStorage.shared.s3BatchAddPhotos([model], bucket: .IM_IMG) { [weak self] result in
|
|
guard let self = self else { return }
|
|
if result {
|
|
self.uploadUrl = model.remoteFullPath
|
|
}
|
|
self.imageUploadComplete?(result, model)
|
|
}
|
|
return model
|
|
}else {
|
|
let model = UploadPhotoM()
|
|
model.image = image
|
|
model.imageSize = image.pixelSize
|
|
model.isAutoCheckImage = checkImage
|
|
// Unknown: [NSDate date] timestamp implementation
|
|
model.addThisItemTimeStamp = Int(Date().timeIntervalSince1970) // Placeholder for timestamp
|
|
CloudStorage.shared.s3BatchAddPhotos([model], bucket: .IM_IMG) { [weak self] result in
|
|
guard let self = self else { return }
|
|
if result {
|
|
self.uploadUrl = model.remoteFullPath
|
|
}
|
|
self.imageUploadComplete?(result, model)
|
|
}
|
|
return model
|
|
}
|
|
}
|
|
}
|