如何实现本地前端向Heroku后端上传图片?技术方向咨询
Optimal Approach for Your Heroku-Powered Image Classification Setup
Hey Rob, here's a straightforward breakdown of the technical direction you should take—no unnecessary complexity:
Skip the SSH-connected independent web server entirely
Heroku is a Platform-as-a-Service (PaaS) that hosts your Python app directly as a web service. You don’t need a separate server or SSH for this workflow. Just build a simple API using a framework likeFlaskorDjangoin your Python app, expose a POST endpoint that accepts image uploads, and your local frontend can send requests straight to this Heroku-hosted endpoint via HTTP.Amazon S3 is optional, based on your persistence needs
- If you only need images temporarily for classification (and don’t need to keep them after processing), you don’t need S3. Heroku can receive the image, process it in its ephemeral file system, then discard the image once you’ve saved the classification result to CSV. Just note that Heroku’s local file system resets when your app restarts, so don’t rely on it for long-term storage.
- If you need to keep uploaded images for future reference, or if you want to persist your CSV files long-term (since Heroku’s local storage isn’t durable), S3 is a great fit. Use the
boto3library in your Python app to upload images to S3 after receiving them, and save your final CSV files to S3 as well.
Core Technical Focus Areas
- Build a Flask/Django API endpoint that accepts
multipart/form-datarequests (the standard for file uploads) from your frontend. - Use JavaScript’s Fetch API or Axios in your local HTML/JS frontend to send selected images to this Heroku endpoint.
- For CSV persistence: If you don’t want to use S3, consider Heroku add-ons like PostgreSQL to store classification results, then generate CSV files on demand. If you prefer file-based storage, S3 is the reliable choice.
内容的提问来源于stack exchange,提问作者Rob
相关产品推荐
相关产品推荐

