emforhs566920
@emforhs566920
Reviews Written
7
Average Rating
5.0
Posts
Q&A
์ฌ๋ฌ ์ฌ์ง ์ค ์ผ๋ถ ์ฌ์ง์ ํ์ฉ ์ฌ์ด์ฆ ์ด๊ณผ๋ก ์คํจํ ๊ฒฝ์ฐ์ ๋ํด
๋ฐ์ ์ฝ๋ ๋์๋์๋๋ถ ์์ผ์ค๊น ์ฒจ๋ถํฉ๋๋ค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
Q&A
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




