Skip to content

Commit

Permalink
feat/#196 : storage 모듈 삭제
Browse files Browse the repository at this point in the history
  • Loading branch information
shinythinking committed Dec 3, 2024
1 parent da34527 commit 22b6cca
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 77 deletions.
1 change: 0 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,4 @@ dependencies {
implementation(projects.data.episode)
implementation(projects.data.user)
implementation(projects.data.mygroup)
implementation(projects.data.storage)
}
14 changes: 0 additions & 14 deletions data/storage/build.gradle.kts

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 1 addition & 0 deletions data/user/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ dependencies {
implementation(projects.core.firebase)
implementation(platform(libs.firebase.bom))
implementation(libs.firebase.firestore)
implementation(libs.firebase.storage)
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
package com.boostcamp.mapisode.user

import androidx.core.net.toUri
import com.boostcamp.mapisode.firebase.firestore.FirestoreConstants
import com.boostcamp.mapisode.firebase.firestore.StorageConstants.PATH_IMAGES
import com.boostcamp.mapisode.model.UserModel
import com.boostcamp.mapisode.user.model.toUserFirestoreModel
import com.google.firebase.firestore.FirebaseFirestore
import com.google.firebase.storage.FirebaseStorage
import kotlinx.coroutines.tasks.await
import java.util.Date
import javax.inject.Inject

class UserRepositoryImpl @Inject constructor(database: FirebaseFirestore) : UserRepository {
class UserRepositoryImpl @Inject constructor(
private val database: FirebaseFirestore,
private val storage: FirebaseStorage,
) : UserRepository {
private val userCollection = database.collection(FirestoreConstants.COLLECTION_USER)

override suspend fun createUser(userModel: UserModel) {
Expand Down Expand Up @@ -74,4 +80,18 @@ class UserRepositoryImpl @Inject constructor(database: FirebaseFirestore) : User
throw Exception("Failed to update user", e)
}
}

override suspend fun uploadSingleImageToStorage(
imageUri: String,
uid: String,
): String {
val imageRef = storage.reference.child("$PATH_IMAGES/$uid/0")
return try {
val uploadTask = imageRef.putFile(imageUri.toUri()).await()
val downloadUrl = uploadTask.task.result.storage.downloadUrl.await()
downloadUrl.toString()
} catch (e: Exception) {
throw e
}
}
}
7 changes: 0 additions & 7 deletions domain/storage/build.gradle.kts

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ interface UserRepository {
suspend fun isUserExist(uid: String): Boolean

suspend fun updateUserNameAndProfileUrl(uid: String, userName: String, profileUrl: String)
suspend fun uploadSingleImageToStorage(imageUri: String, uid: String): String
}
1 change: 0 additions & 1 deletion feature/login/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ dependencies {
implementation(projects.core.auth)
implementation(projects.domain.user)
implementation(projects.domain.mygroup)
implementation(projects.domain.storage)
implementation(libs.bundles.coil)
}
1 change: 0 additions & 1 deletion feature/mypage/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,5 @@ dependencies {
implementation(libs.androidx.browser)
implementation(projects.core.auth)
implementation(projects.domain.user)
implementation(projects.domain.storage)
implementation(projects.domain.mygroup)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import com.boostcamp.mapisode.mypage.R
import com.boostcamp.mapisode.mypage.intent.ProfileEditIntent
import com.boostcamp.mapisode.mypage.sideeffect.ProfileEditSideEffect
import com.boostcamp.mapisode.mypage.state.ProfileEditState
import com.boostcamp.mapisode.storage.StorageRepository
import com.boostcamp.mapisode.ui.base.BaseViewModel
import com.boostcamp.mapisode.user.UserRepository
import dagger.hilt.android.lifecycle.HiltViewModel
Expand All @@ -17,7 +16,6 @@ import javax.inject.Inject

@HiltViewModel
class ProfileEditViewModel @Inject constructor(
private val storageRepository: StorageRepository,
private val groupRepository: GroupRepository,
private val userRepository: UserRepository,
private val userPreferenceDataStore: UserPreferenceDataStore,
Expand Down Expand Up @@ -109,7 +107,7 @@ class ProfileEditViewModel @Inject constructor(

private suspend fun getStorageUrl(): String {
try {
return storageRepository.uploadSingleImageToStorage(
return userRepository.uploadSingleImageToStorage(
imageUri = currentState.profileUrl,
uid = currentState.uid,
)
Expand Down

0 comments on commit 22b6cca

Please sign in to comment.