Skip to content

Commit

Permalink
[misc] #62 ktlint format
Browse files Browse the repository at this point in the history
  • Loading branch information
lsakee authored and Sangwook123 committed Jul 19, 2024
1 parent 5f1deb0 commit 3fb71c8
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,16 @@ class UploadRepositoryImpl @Inject constructor(
}

override suspend fun uploadThumbnailToS3Bucket(url: String, file: File): Result<String> =
runCatching {
remoteUploadDataSource.uploadThumbnailToS3Bucket(url, file)
}.recoverCatching { exception ->
when (exception) {
is HttpException -> {
throw ApiError(exception.message())
}
else -> {
throw exception
runCatching {
remoteUploadDataSource.uploadThumbnailToS3Bucket(url, file)
}.recoverCatching { exception ->
when (exception) {
is HttpException -> {
throw ApiError(exception.message())
}
else -> {
throw exception
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ package com.record.video.source.remote

import com.record.video.model.remote.request.RequestPostVideoDto
import com.record.video.model.remote.response.ResponseGetPresignedUrlDto
import okhttp3.MultipartBody
import java.io.File

interface RemoteUploadDataSource {
suspend fun getUploadUrl(): ResponseGetPresignedUrlDto
suspend fun uploadRecord(requestPostVideoDto: RequestPostVideoDto)
suspend fun uploadVideoToS3Bucket(url: String, file: File):String
suspend fun uploadThumbnailToS3Bucket(url: String, file: File):String
suspend fun uploadVideoToS3Bucket(url: String, file: File): String
suspend fun uploadThumbnailToS3Bucket(url: String, file: File): String
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ import com.record.designsystem.component.snackbar.SnackBarType
import com.record.keyword.repository.KeywordRepository
import com.record.ui.base.BaseViewModel
import com.record.upload.extension.GalleryVideo
import com.record.upload.extension.uploadFileToS3ThumbnailPresignedUrl
import com.record.upload.model.VideoInfo
import com.record.upload.repository.UploadRepository
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import java.io.File
import java.net.URL
Expand Down Expand Up @@ -55,7 +53,7 @@ class UploadViewModel @Inject constructor(
uploadRepository.uploadThumbnailToS3Bucket(
uiState.value.thumbnailUrl,
file,
) .onSuccess{
).onSuccess {
b = removeQueryParameters(it)
Log.d("testUploadthumbnailUrl", "$b")
uploadRecord(a, b)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,11 @@ fun formatDuration(durationMillis: Long): String {
return String.format("%d:%02d", minutes, seconds)
}

//fun uploadFileToS3PresignedUrl(
// fun uploadFileToS3PresignedUrl(
// presignedUrl: String,
// file: File,
// callback: (Boolean, String) -> Unit,
//) {
// ) {
// val client = OkHttpClient()
// val mediaType = "application/octet-stream".toMediaTypeOrNull()
// val requestBody = RequestBody.create(mediaType, file)
Expand All @@ -195,7 +195,7 @@ fun formatDuration(durationMillis: Long): String {
// }
// },
// )
//}
// }

fun uploadFileToS3ThumbnailPresignedUrl(
context: Context,
Expand Down
5 changes: 1 addition & 4 deletions remote/video/src/main/java/com/record/video/api/BucketApi.kt
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
package com.record.video.api

import okhttp3.MultipartBody
import okhttp3.RequestBody
import okhttp3.ResponseBody
import retrofit2.Response
import retrofit2.http.Body
import retrofit2.http.Header
import retrofit2.http.Multipart
import retrofit2.http.PUT
import retrofit2.http.Part
import retrofit2.http.Url

interface BucketApi {
@PUT
suspend fun uploadVideoWithS3Video(
@Url url: String,
@Body requestBody: RequestBody,
@Header("Content-Type") contentType: String = "application/octet-stream"
@Header("Content-Type") contentType: String = "application/octet-stream",
): Response<ResponseBody>
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import javax.inject.Inject
class RemoteUploadDataSourceImpl @Inject constructor(
private val uploadApi: UploadApi,
private val bucketApi: BucketApi,
@ApplicationContext private val context: Context
@ApplicationContext private val context: Context,
) : RemoteUploadDataSource {
override suspend fun getUploadUrl(): ResponseGetPresignedUrlDto =
uploadApi.getPresignedUploadUrl()
Expand All @@ -27,13 +27,13 @@ class RemoteUploadDataSourceImpl @Inject constructor(
requestPostVideoDto: RequestPostVideoDto,
) = uploadApi.postRecord(requestPostVideoDto)

override suspend fun uploadVideoToS3Bucket(url: String, file: File): String {
override suspend fun uploadVideoToS3Bucket(url: String, file: File): String {
val videoPath = file.absolutePath
val mediaType = "application/octet-stream".toMediaTypeOrNull()
val requestBody = RequestBody.create(mediaType, videoPath)
val url = URL(bucketApi.uploadVideoWithS3Video(url, requestBody).raw().request.url.toString())
Log.d("testUrl","$url")
return URL(url.protocol, url.host, url.port, url.path).toString()
Log.d("testUrl", "$url")
return URL(url.protocol, url.host, url.port, url.path).toString()
}

override suspend fun uploadThumbnailToS3Bucket(url: String, file: File): String {
Expand All @@ -43,8 +43,7 @@ class RemoteUploadDataSourceImpl @Inject constructor(
val mediaType = "application/octet-stream".toMediaTypeOrNull()
val requestBody = RequestBody.create(mediaType, outputImagePath)
val url = URL(bucketApi.uploadVideoWithS3Video(url, requestBody).raw().request.url.toString())
Log.d("testUrl2","$url")
Log.d("testUrl2", "$url")
return URL(url.protocol, url.host, url.port, url.path).toString()

}
}

0 comments on commit 3fb71c8

Please sign in to comment.