Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ public struct CreateCollectionEntity: Encodable {
public let isPublic: Bool
public let contentList: [CreateCollectionContents]

public init(imgaeUrl: String,
title: String,
description: String,
isPublic: Bool,
contentList: [CreateCollectionContents]
public init(
imgaeUrl: String,
title: String,
description: String,
isPublic: Bool,
contentList: [CreateCollectionContents]
) {
self.imageUrl = imgaeUrl
self.title = title
Expand All @@ -34,11 +35,18 @@ public extension CreateCollectionEntity {
public let contentId: Int64
public let isSpoiler: Bool
public let reason: String
public let customImage: String?

public init(contentId: Int64, isSpoiler: Bool, reason: String) {
public init(
contentId: Int64,
isSpoiler: Bool,
reason: String,
customImage customImageKey: String? = nil
) {
self.contentId = contentId
self.isSpoiler = isSpoiler
self.reason = reason
self.customImage = customImageKey
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// UploadCollectionImageUseCase.swift
// Domain
//
// Created by 소은 on 5/29/26.
//

import Combine
import Foundation
import UIKit

import Entity
import Repository

public protocol UploadCollectionImageUseCase {
func callAsFunction(_ image: UIImage) -> AnyPublisher<String, Error>
}

public final class DefaultUploadCollectionImageUseCase: UploadCollectionImageUseCase {

private let storageRepository: StorageRepository

public init(storageRepository: StorageRepository) {
self.storageRepository = storageRepository
}

public func callAsFunction(_ image: UIImage) -> AnyPublisher<String, any Error> {
storageRepository.fetchPresignedURL(uploadType: .collectionContent, fileExtension: .png)
.flatMap { [storageRepository] presignedUrlInfoEntity in
guard let imageData = image.pngData() else {
return Fail<String, Error>(error: FlintError.imageEncodingFailed).eraseToAnyPublisher()
}
return storageRepository.uploadImageToS3(imageData: imageData, uploadUrl: presignedUrlInfoEntity.uploadUrl, fileExtension: .png)
.map { _ in return presignedUrlInfoEntity.key }
.eraseToAnyPublisher()
}
.eraseToAnyPublisher()
}
}
10 changes: 9 additions & 1 deletion FLINT/FLINT/Dependency/DIContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ typealias DependencyFactory = ViewControllerFactory &
CreateCollectionViewModelFactory &
AddContentSelectViewModelFactory &
CollectionFolderListViewModelFactory &
CollectionDetailViewModelFactory
CollectionDetailViewModelFactory &
StorageRepositoryFactory &
UploadCollectionImageUseCaseFactory

final class DIContainer: DependencyFactory {

Expand All @@ -54,6 +56,12 @@ final class DIContainer: DependencyFactory {

lazy var presignedUrlService: any PresignedUrlService = DefaultPresignedUrlService()

// MARK: - UseCase

lazy var uploadCollectionImageUseCase: UploadCollectionImageUseCase = DefaultUploadCollectionImageUseCase(
storageRepository: makeStorageRepository()
)

// MARK: - Init

init() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// UploadCollectionImageUseCaseFactory.swift
// FLINT
//
// Created by 소은 on 2026.05.29.
//

import Foundation

import Domain

protocol UploadCollectionImageUseCaseFactory: StorageRepositoryFactory {
func makeUploadCollectionImageUseCase() -> UploadCollectionImageUseCase
}

extension UploadCollectionImageUseCaseFactory {
func makeUploadCollectionImageUseCase() -> UploadCollectionImageUseCase {
return DefaultUploadCollectionImageUseCase(storageRepository: makeStorageRepository())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ import Foundation

import Presentation

extension CreateCollectionViewControllerFactory where Self: CreateCollectionViewModelFactory & ViewControllerFactory {
extension CreateCollectionViewControllerFactory where Self: CreateCollectionViewModelFactory & ViewControllerFactory & UploadCollectionImageUseCaseFactory {
func makeCreateCollectionViewController() -> CreateCollectionViewController {
let vm = makeCreateCollectionViewModel()
return CreateCollectionViewController(viewModel: vm, viewControllerFactory: self)
return CreateCollectionViewController(
viewModel: vm,
uploadImageUseCase: makeUploadCollectionImageUseCase(),
viewControllerFactory: self
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import UIKit

final class CustomPageControl: BaseView {
public final class CustomPageControl: BaseView {

// MARK: - Property

Expand Down
Loading