Skip to content

본문 이미지 fileKey 를 URL 에서 역산하지 않고 upload() 반환값을 쓴다 — #1017 반영 후속 #1125

Closed

Description

@OnlyReadOneBook

📜 Overview (Required)

마음의 기록 작성 2곳이 본문 img src 에 실을 fileKey 를 업로드 URL 에서 문자열로 역산한다.

// feature/mindrecord/presentation/.../util/HtmlText.kt
fun String.toUploadedFileKey(): String =
    if (contains("://")) substringAfter("://").substringAfter('/') else this

fun String.toWireContent(uploadedImageUrls: Set<String>): String =
    uploadedImageUrls.fold(this) { content, url -> content.replace(url, url.toUploadedFileKey()) }

이 방식은 fileUrl == "<스킴>://<호스트>/" + fileKey 를 가정한다. CDN 이 경로 프리픽스를 붙이거나(https://cdn/bucket/mindrecords/…) 쿼리스트링이 붙으면 조용히 틀린 키가 나가고, 증상은 #549 가 고친 것과 같은 «저장은 됐는데 이미지가 안 뜬다» 다.

왜 지금까지 역산이었나 — 그리고 무엇이 바뀌나

역산은 몰라서 쓴 게 아니라 코어가 fileKey 를 버려서 쓴 우회다. HtmlText.kt 의 KDoc 이 그 사정을 적어 두고 있다.

권위 있는 출처는 presigned 응답의 fileKey 인데 PhotoUploadRepository.upload() 가 fileUrl 만 돌려주며 버린다 — CDN 이 경로 프리픽스나 쿼리스트링을 붙이면 조용히 틀린 키가 된다. 반환을 넓히는 것은 core:data 범위라 별건으로 둔다 (#1017).

그 별건이 #1017(PR #1094)이다. 머지되면 upload() 가 UploadedFile(fileUrl, fileKey) 를 돌려주므로 역산의 전제가 사라진다. 이 이슈는 그 뒤에 남는 우회를 걷어내는 후속이다.

무엇을 하면 되나

소비처는 DailyQuestionWriteViewModel(데일리질문 #549)과 DiaryWriteViewModel(일기 #1016) 두 곳이다.

📌 Child Issue(Optional)

No response

📍 Note (Optional)

Activity

  1. added a commit that references this issue on Aug 25, 2026
  2. changed the title [-]refactor(mindrecord): 본문 이미지 fileKey 를 URL 에서 역산하지 않고 upload() 반환값을 쓴다 — #1017 반영 후속[/-] [+]본문 이미지 fileKey 를 URL 에서 역산하지 않고 upload() 반환값을 쓴다 — #1017 반영 후속[/+] on Aug 28, 2026
  3. added
    refactor동작 변경 없이 코드 구조·책임·경계를 개선하는 작업
    area:mindrecord마음의 기록 기능 영역
    on Aug 28, 2026
  4. added
    pr-open이 이슈를 구현하는 PR 이 열려 있다 — base 가 기본 브랜치가 아니어도 드러낸다
    on Aug 31, 2026
  5. removed
    pr-open이 이슈를 구현하는 PR 이 열려 있다 — base 가 기본 브랜치가 아니어도 드러낸다
    on Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:mindrecord마음의 기록 기능 영역refactor동작 변경 없이 코드 구조·책임·경계를 개선하는 작업

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions