Fix profile picture uploads from the app

Expo's fetch rejects React Native's { uri, name, type } FormData parts ("Unsupported FormDataPart
implementation"), so every upload failed. Upload an expo-file-system File instead, shrunk to 1024 px
first. The server also takes bigger photos (25 MB, sharp's default pixel limit) and logs why a
picture couldn't be read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011Y2iUsKEWDuRGjK5FPmcUP
This commit is contained in:
2026-10-15 13:20:12 -04:00
co-authored by Claude Opus 5.5
parent b705bfcce4
commit 31aed8dec4
6 changed files with 49 additions and 10 deletions
+8
View File
@@ -22,6 +22,14 @@ const photo = () =>
.toBuffer();
describe('avatars', () => {
it('takes a full-size photo from a high-resolution phone camera (64 MP)', async () => {
const { token } = await createUser(app(), 'hires');
const big = await sharp({ create: { width: 8000, height: 8000, channels: 3, background: '#203040' } }).jpeg().toBuffer();
const { payload, headers } = multipart(big);
const res = await app().inject({ method: 'POST', url: '/me/avatar', payload, headers: { ...headers, ...bearer(token) } });
expect(res.statusCode).toBe(200);
});
it('resizes, re-encodes and serves an uploaded picture', async () => {
const { token, user } = await createUser(app(), 'alice');
const { payload, headers } = multipart(await photo());