Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat] 밈 등록하기 기능 #256

Merged
merged 7 commits into from
Oct 1, 2024
Merged

Conversation

Ricky-Android
Copy link
Collaborator

@Ricky-Android Ricky-Android commented Sep 30, 2024

작업 내역 (Required)

  • UI 예외처리
  • 갤러리에서 이미지 불러오기
  • multipart form 형식으로 밈 업로드하기
  • 네트워크 예외처리

@EvergreenTree97 EvergreenTree97 marked this pull request as ready for review October 1, 2024 09:41
Copy link
Collaborator

@hj1115hj hj1115hj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

진짜 고생했어!!

Comment on lines +76 to +105
val contentResolver: ContentResolver = context.contentResolver
val fileName = getFileName(contentResolver, uri) ?: return null // 파일 이름 얻기
val tempFile = File(context.cacheDir, fileName)

try {
val inputStream: InputStream? = contentResolver.openInputStream(uri)
val outputStream: OutputStream = FileOutputStream(tempFile)

inputStream?.use { input ->
outputStream.use { output ->
input.copyTo(output)
}
}
return tempFile
} catch (e: Exception) {
e.printStackTrace()
}
return null
}

private fun getFileName(contentResolver: ContentResolver, uri: Uri): String? {
val cursor = contentResolver.query(uri, null, null, null, null)
return cursor?.use {
if (it.moveToFirst()) {
val index = it.getColumnIndex("_display_name")
it.getString(index)
} else null
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이렇게 했을 때 실제 fileName이랑 photopicker uri에서 fileName 얻어왔을 때랑 동일해??

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

정상 업로드 된것을 봐서는 동일해

Comment on lines +45 to +50
val imagePicker =
rememberLauncherForActivityResult(contract = ActivityResultContracts.PickVisualMedia()) { uri ->
if (uri != null) {
onIntent(RegisterIntent.SetImageFromGallery(uri.toString()))
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

각 API Level에 해당하는 권한체크는 없어도 되려나?

<!-- Devices running Android 12L (API level 32) or lower  -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32" />

<!-- Devices running Android 13 (API level 33) or higher -->
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />

<!-- To handle the reselection within the app on Android 14 (API level 34) -->
<uses-permission android:name="android.permission.READ_MEDIA_VISUAL_USER_SELECTED" />
`

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://mundroid.tistory.com/2, https://developer.android.com/training/data-storage/shared/photopicker
따로 권한을 명시하지 않아도 되고, 31버전이하의 경우 문서 선택기로 열린다고 하더라구
커스텀 갤러리가 아니라면 휘뚜루마뚜루 써도 될듯?

@EvergreenTree97 EvergreenTree97 merged commit 93a161b into develop Oct 1, 2024
@EvergreenTree97 EvergreenTree97 deleted the feat/image_upload branch October 1, 2024 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants