Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jun 11, 2025

The image upload system was failing because Imgur's API is blocked in Taiwan. This PR fixes the issue by implementing direct backend uploads using the new multi-backend image upload service introduced in the backend.

Problem

Users in Taiwan were unable to upload factory photos due to the "上傳錯誤" (upload error) message. The frontend was trying to upload images to Imgur first, then sending the URL to the backend, but Imgur's API is blocked in Taiwan.

Solution

Updated the frontend to use direct backend uploads instead of the Imgur-first approach:

Factory Images (Main Fix)

  • Before: Upload to Imgur → Send URL to /factories/{id}/images
  • After: Direct upload to /factories/{id}/images/upload with multipart form data

General Images

  • Before: Upload to Imgur → Send URL to /images
  • After: Direct upload to /images with multipart form data

Key Changes

  1. Replaced updateFactoryImages to use the new /factories/{id}/images/upload endpoint
  2. Updated uploadImages to upload directly to backend /images endpoint
  3. Removed unused Imgur code (uploadToImgur, uploadExifAndGetToken, Imgur constants)
  4. Preserved all functionality: EXIF data extraction, contact information, error handling

Technical Details

The new implementation:

  • Uploads image files directly as multipart form data
  • Includes EXIF metadata (GPS coordinates, datetime) in the request
  • Passes contact information (nickname, contact) for factory images
  • Maintains the same return format for backward compatibility
  • Leverages the backend's new multi-backend upload service (Imgur → ImageBB → Cloudflare R2 → Local fallback)

Testing

  • ✅ Code compiles successfully
  • ✅ Passes linting with no new issues
  • ✅ Maintains existing TypeScript interfaces
  • ✅ Preserves all existing functionality

This change ensures image uploads work reliably regardless of regional service restrictions while maintaining full backward compatibility.

Fixes #185.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits June 11, 2025 13:45
Co-authored-by: Yukaii <4230968+Yukaii@users.noreply.github.com>
Co-authored-by: Yukaii <4230968+Yukaii@users.noreply.github.com>
Copilot AI changed the title [WIP] 回報系統無法順利上傳照片 Fix image upload by replacing Imgur with direct backend upload Jun 11, 2025
Copilot AI requested a review from Yukaii June 11, 2025 13:49
@netlify
Copy link

netlify bot commented Jun 22, 2025

Deploy Preview for disfactory-frontend ready!

Name Link
🔨 Latest commit 2c1f34c
🔍 Latest deploy log https://app.netlify.com/projects/disfactory-frontend/deploys/6857b311a3bc3a00083fdb6a
😎 Deploy Preview https://deploy-preview-186--disfactory-frontend.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@Yukaii Yukaii marked this pull request as ready for review June 22, 2025 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

回報系統無法順利上傳照片

2 participants