재환
@emforhs566920
수강평 작성수
7
평균평점
5.0
게시글
질문&답변
여러 사진 중 일부 사진의 허용 사이즈 초과로 실패한 경우에 대해
반영 코드 도움되시는분 있으실까 첨부합니다export async function createPostWithImages({ content, images, userId, }: { content: string; images: File[]; userId: string; }) { // 1. 새로운 포스트 생성 const post = await createPost(content); if (images.length === 0) return post; const uploadedFilePaths: string[] = []; try { // 2. 이미지 업로드 const imageUrls = await Promise.all( images.map((image) => { const fileExtension = image.name.split(".").pop() || "webp"; const fileName = `${Date.now()}-${crypto.randomUUID()}.${fileExtension}`; const filePath = `${userId}/${post.id}/${fileName}`; uploadedFilePaths.push(filePath); return uploadImage({ file: image, filePath, }); }), ); // 3. 포스트 테이블 업데이트 const updatedPost = await updatePost({ id: post.id, image_urls: imageUrls, }); return updatedPost; } catch (error) { await Promise.all([ deletePost(post.id), uploadedFilePaths.length > 0 ? deleteImages(uploadedFilePaths) : Promise.resolve(), ]); throw error; } }
- 2
- 2
- 47
질문&답변
revalidateTag 에 대해서 질문이 있습니다.
강의 들으면서 다른 분들은 어떤 부분이 궁금한지 Q&A를 보던 중, 저도 실험을 해보고 공식문서를 찾아봤습니다.공식 문서에서는“revalidateTag invalidates all entries associated with that tag”“When using fetch, you have the option to tag cache entries with one or more tags. Then, you can call revalidateTag to revalidate all entries associated with that tag.”라고 되어 있어서, 같은 태그 문자열이 정확히 일치해야 캐시 무효화가 일어난다고 설명되어 있습니다.그런데 실제로 실험해보면, 태그의 접두사 부분(review-, book-review- 등)은 달라도 ${bookId} 식별자가 같으면 동일한 캐시 그룹으로 인식되어 재검증이 되는 것처럼 보입니다.즉, 태그명 전체보다 데이터를 구분할 수 있는 식별자(bookId) 가 캐시 그룹을 구분하는 핵심 역할을 하는 것처럼 동작하는 것 같습니다. 혹시 내부적으로 fetch URL 단위 캐시와 태그 캐시가 연결되어 있어서 이런 결과가 나오는 걸까요?
- 0
- 3
- 56




