I am working on a backend API to store articles and their metadata, the API is designed as the following way.
- User should call
POST /api/articles
to create a file object with only its metadata at first, and get an object ID 123; - Then the user could call
POST /api/articles/123/file
to upload the file to backend.
A simple way to implement step 2 is to first upload file to my backend server, and then in the backend server I can upload the file to a s3 bucket. But this method is inefficent as the file has been uploaded 2 times (browser -> backend -> s3).
I learn that s3 is allowed to create presigned url for such use case, but I don't know how to use it with my design. One possbile solution is to response with a 302 redirect at Step 2 but I don't fine any cases to use it that way.