การแปลงรูปภาพและ URL แบบลงลายเซ็น
แสดงรูปภาพที่ปรับขนาดและเพิ่มประสิทธิภาพแบบทันที พร้อมมอบสิทธิ์เข้าถึงไฟล์ส่วนตัวชั่วคราวผ่าน URL แบบลงลายเซ็นของ Supabase Storage
การแปลงรูปภาพและ URL แบบลงลายเซ็น เป็นบทเรียน Supabase Backend as a Service ฟรีบน CoddyKit นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Supabase Backend as a Service และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Supabase Backend as a Service มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
Smarter File Delivery
Supabase Storage can transform images on request and create signed URLs for time-limited access to private files. Both reduce custom backend work.
Public vs Private Buckets
Public buckets serve files via a permanent URL. Private buckets require a signed URL or an authenticated request, controlled by policies.
Getting a Public URL
For public buckets, build the URL directly, no token needed.
const { data } = supabase.storage
.from('avatars')
.getPublicUrl('user-42.png');
console.log(data.publicUrl);On-the-Fly Resizing
Pass transform options to request a resized version. Supabase generates and caches it.
const { data } = supabase.storage
.from('avatars')
.getPublicUrl('user-42.png', {
transform: { width: 100, height: 100, resize: 'cover' }
});Why Transform at the Edge?
Serving a 100px thumbnail instead of a full-size photo saves bandwidth and speeds up pages, without storing many copies yourself.
Quality and Format
You can also tune quality and request modern formats to shrink payloads further.
function thumbOpts(size) {
return { width: size, height: size, quality: 75, resize: 'cover' };
}
console.log(thumbOpts(64));Creating a Signed URL
For private files, generate a URL that expires after a set number of seconds.
const { data } = await supabase.storage
.from('invoices')
.createSignedUrl('inv-2026.pdf', 60);
console.log(data.signedUrl);Choosing an Expiry
Keep expiry as short as the use case allows. A download link might need 60 seconds; an embedded image might need an hour.
function expirySeconds(useCase) {
return useCase === 'download' ? 60 : 3600;
}
console.log(expirySeconds('download'));Signed URLs With Transforms
You can combine a signed URL with an image transform to serve resized private images securely.
Caching Behavior
Transformed images are cached at the edge, so repeated requests for the same size are fast. Vary the size sparingly to keep cache hits high.
Putting It Together
Use public URLs and transforms for open assets, and signed URLs for private files, with short expiries and edge caching for performance.
Quick Check
Test your understanding of URLs and transforms.
Recap
You learned to build public URLs, apply on-the-fly image transforms for performance, and create expiring signed URLs for private files, plus how edge caching keeps it fast.
คำถามที่พบบ่อย
บทเรียน “การแปลงรูปภาพและ URL แบบลงลายเซ็น” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “การแปลงรูปภาพและ URL แบบลงลายเซ็น” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Supabase Backend as a Service ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Supabase Backend as a Service มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “การแปลงรูปภาพและ URL แบบลงลายเซ็น”
แสดงรูปภาพที่ปรับขนาดและเพิ่มประสิทธิภาพแบบทันที พร้อมมอบสิทธิ์เข้าถึงไฟล์ส่วนตัวชั่วคราวผ่าน URL แบบลงลายเซ็นของ Supabase Storage คุณปฏิบัติ Supabase Backend as a Service ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Supabase Backend as a Service หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน Supabase Backend as a Service บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน
บทเรียน “การแปลงรูปภาพและ URL แบบลงลายเซ็น” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน Supabase Backend as a Service นี้ได้ไหม
ได้ บทเรียน Supabase Backend as a Service ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- การจัดเก็บไฟล์ในบักเก็ตของ Supabase
- การจัดการการเข้าถึงด้วยนโยบาย
- การอัปโหลดและดึงสื่อ
- การแปลงรูปภาพและ URL แบบลงลายเซ็น