-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
109 changed files
with
1,915 additions
and
448 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/file/FileDataSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* Designed and developed by Wedemy 2023. | ||
* | ||
* Licensed under the MIT. | ||
* Please see full license: https://github.com/Wedemy/eggeum-android/blob/main/LICENSE | ||
*/ | ||
|
||
package us.wedemy.eggeum.android.data.datasource.file | ||
|
||
import us.wedemy.eggeum.android.data.model.file.FileResponse | ||
|
||
public interface FileDataSource { | ||
public suspend fun uploadImageFile(uri: String): FileResponse? | ||
} |
40 changes: 40 additions & 0 deletions
40
data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/file/FileDataSourceImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Designed and developed by Wedemy 2023. | ||
* | ||
* Licensed under the MIT. | ||
* Please see full license: https://github.com/Wedemy/eggeum-android/blob/main/LICENSE | ||
*/ | ||
|
||
package us.wedemy.eggeum.android.data.datasource.file | ||
|
||
import android.content.Context | ||
import android.net.Uri | ||
import javax.inject.Inject | ||
import okhttp3.MediaType.Companion.toMediaTypeOrNull | ||
import okhttp3.MultipartBody | ||
import okhttp3.RequestBody.Companion.asRequestBody | ||
import us.wedemy.eggeum.android.data.model.file.FileResponse | ||
import us.wedemy.eggeum.android.data.service.FileService | ||
import us.wedemy.eggeum.android.data.util.FileManager | ||
import us.wedemy.eggeum.android.data.util.safeRequest | ||
|
||
public class FileDataSourceImpl @Inject constructor( | ||
private val context: Context, | ||
private val service: FileService, | ||
private val fileManager: FileManager, | ||
) : FileDataSource { | ||
override suspend fun uploadImageFile(uri: String): FileResponse? { | ||
val imageFile = fileManager.getFileForUploadImageFormat(context, Uri.parse(uri))!! | ||
val imageRequestBody = imageFile.asRequestBody("image/*".toMediaTypeOrNull()) | ||
|
||
return safeRequest { | ||
service.uploadImageFile( | ||
MultipartBody.Part.createFormData( | ||
name = "file", | ||
filename = imageFile.name, | ||
body = imageRequestBody, | ||
), | ||
) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
data/src/main/kotlin/us/wedemy/eggeum/android/data/di/AppModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Designed and developed by Wedemy 2023. | ||
* | ||
* Licensed under the MIT. | ||
* Please see full license: https://github.com/Wedemy/eggeum-android/blob/main/LICENSE | ||
*/ | ||
|
||
package us.wedemy.eggeum.android.data.di | ||
|
||
import android.content.Context | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.android.qualifiers.ApplicationContext | ||
import dagger.hilt.components.SingletonComponent | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
internal object AppModule { | ||
|
||
@Provides | ||
@Singleton | ||
internal fun provideApplicationContext(@ApplicationContext context: Context): Context = context | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
data/src/main/kotlin/us/wedemy/eggeum/android/data/di/FileManagerModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package us.wedemy.eggeum.android.data.di | ||
|
||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import javax.inject.Singleton | ||
import us.wedemy.eggeum.android.data.util.FileManager | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
public object FileManagerModule { | ||
|
||
@Provides | ||
@Singleton | ||
public fun provideFileManager(): FileManager { | ||
return FileManager | ||
} | ||
} |
Oops, something went wrong.