3.8 KiB
Image Upload - Ready to Test! ✅
Configuration Complete
All backend configuration is done. Images should now work properly!
What Was Configured:
- ✅ Custom Domain Connected:
media.sojorn.net→ R2 bucketsojorn-media - ✅ Environment Variable Set:
R2_PUBLIC_URL=https://media.sojorn.net - ✅ Edge Function Deployed: Updated
upload-imagefunction using custom domain - ✅ DNS Verified: Domain resolving to Cloudflare CDN
- ✅ API Queries Fixed: All post queries include
image_urlfield
Test Instructions
1. Upload a Test Image
In the app:
- Tap the compose/create post button
- Add an image from your device
- (Optional) Apply a filter
- Write some text for the post
- Submit the post
2. Verify the Image
Expected behavior:
- Image uploads successfully
- Post appears in feed with image visible
- Image URL format:
https://media.sojorn.net/{uuid}.jpg
If it works: Images will now display everywhere (feed, profiles, chains) ✅
3. Check Database (Optional)
To verify the URL format:
SELECT id, image_url, created_at
FROM posts
WHERE image_url IS NOT NULL
ORDER BY created_at DESC
LIMIT 5;
Expected format: https://media.sojorn.net/[uuid].[ext]
Troubleshooting
Images Still Not Showing
If images don't display after uploading:
1. Check Edge Function Logs
npx supabase functions logs upload-image --project-ref zwkihedetedlatyvplyz
Look for:
- Upload errors
- "Missing R2_PUBLIC_URL" errors (shouldn't happen now)
- R2 authentication errors
2. Test Domain Directly
After uploading an image, copy its URL from the database and test:
curl -I https://media.sojorn.net/[filename-from-db]
Should return HTTP/1.1 200 OK or HTTP/2 200
3. Hot Reload the App
In the Flutter terminal, press:
rfor hot reloadRfor full restart
4. Check App Logs
Look in the Flutter console for:
- Network errors
- Image loading failures
- CORS errors (shouldn't happen with proper R2 CORS)
Common Issues
Issue: "Missing R2_PUBLIC_URL" error in logs Solution: Secret might not have propagated. Wait 1-2 minutes and try again.
Issue: Image returns 404 on custom domain Solution: File might not have uploaded to R2. Check edge function logs for upload errors.
Issue: Image returns 403 Forbidden Solution: R2 bucket permissions issue. Verify API token has "Object Read & Write" permissions.
What's Next
Once images are working:
Immediate
- Upload a few test images with different formats (JPG, PNG)
- Test with different image sizes
- Try different filters
- Verify images appear in all views (feed, profile, chains)
Future Enhancements (Optional)
From IMAGE_UPLOAD_IMPLEMENTATION.md:
- Image compression: Further optimize file sizes
- Multiple images: Allow multiple images per post
- Image galleries: View all images from a user
- Video support: Extend to video uploads
- CDN optimization: Configure Cloudflare caching rules
Documentation
Complete guides available:
- IMAGE_UPLOAD_IMPLEMENTATION.md - Full implementation details
- R2_CUSTOM_DOMAIN_SETUP.md - Custom domain setup guide
Summary
| Component | Status |
|---|---|
| R2 Bucket | ✅ Configured with custom domain |
| Edge Function | ✅ Deployed with R2_PUBLIC_URL |
| Database Schema | ✅ posts.image_url column exists |
| API Queries | ✅ Include image_url field |
| Flutter Model | ✅ Post model parses image_url |
| Widget Display | ✅ PostItem widget shows images |
| Custom Domain | ✅ media.sojorn.net connected |
Ready to test! 🚀
Try uploading an image now and it should work. If you encounter any issues, check the troubleshooting section above.