I have an API with some specific resource say “cars” which have the following actions:

  • Get all Cars
  • Get one car
  • Add one car

for Get all cars and Get one Car, I have a REST api resouce with GET /cars and GET /cars/:car_id.

However adding a new car requires two steps:

  1. Get a presigned-URL to upload the car to S3 from the client
  2. The client should upload the data to S3 directly.

What would be the best approach to add to the existing API? should I use a separate resource endpoint? like GET /presigned-url or should I have a special sub-resource like /cars/presigned-url . Any other ideas?



If using the presigned-URL does not require any special knowledge from the client, you could implement the creation of a car like this:

  1. POST to /cars/
  2. The API creates the presigned-URL
  3. The API responds with a redirect to the S3 URL
  4. The client follows the redirect and posts the data to S3.

Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *