feat: image compress before upload
This commit is contained in:
@@ -27,6 +27,7 @@ import {
|
||||
import { posts, SocialError } from "@/lib/social";
|
||||
import { buildHighlightUrl } from "@/lib/text-highlight";
|
||||
import { getSourceReference } from "@/lib/source-reference";
|
||||
import { compressImage } from "@/lib/compress-image";
|
||||
import { useSharePost } from "@/components/social/share-post-provider";
|
||||
|
||||
const MAX_IMAGES = 5;
|
||||
@@ -75,7 +76,12 @@ export function ComposePost({
|
||||
await Promise.all(
|
||||
picked.map(async (file, i) => {
|
||||
try {
|
||||
const url = await posts.uploadImage(file);
|
||||
// Compress in the browser before the presigned PUT — keeps
|
||||
// R2 storage bounded, makes share pre-fetch fast, strips
|
||||
// EXIF as a side effect. Falls back to the original file
|
||||
// on any decode failure.
|
||||
const compressed = await compressImage(file);
|
||||
const url = await posts.uploadImage(compressed);
|
||||
setImages((prev) => {
|
||||
const next = [...prev];
|
||||
next[baseIndex + i] = { url, uploading: false };
|
||||
|
||||
Reference in New Issue
Block a user