Skip to content

Commit

Permalink
#71 [hotfix] : 초기 이미지 url이 서버 http, https url인경우 null 처리
Browse files Browse the repository at this point in the history
  • Loading branch information
chanubc committed Sep 7, 2024
1 parent b2618b8 commit 7e63ff3
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ import kotlinx.coroutines.withContext
import okhttp3.MultipartBody

suspend fun ContentResolver.createImagePart(uriString: String?, fileName: String): MultipartBody.Part? {
if (uriString.isNullOrEmpty()) return null
val uri = runCatching { Uri.parse(uriString) }.getOrElse { return null }
val uri = runCatching { Uri.parse(uriString ?: return null) }
.getOrNull()
?.takeUnless {
it.scheme.equals("http", ignoreCase = true) || it.scheme.equals("https", ignoreCase = true)
} ?: return null

return withContext(Dispatchers.IO) {
val imageRequestBody = ContentUriRequestBody(this@createImagePart, uri)
Expand Down

0 comments on commit 7e63ff3

Please sign in to comment.