How to design the file operation interface involving status and transactions?

17 Views Asked by At

An interface for publishing projects requires these operations:

  1. Check the status of this item to see if it can be published (only unpublished items can be published)
  2. Backend upload files (there may be many files, and currently a maximum of 10 concurrent uploads are allowed for one request) to the cloud service (object storage)
  3. After all files are successfully uploaded, change the project status to 'Published'
  4. Return the result, the front end ends the loading state and prompts the successful publishing How should this interface be designed? Because the overall process is time-consuming, there is a possibility of failure during the intermediate process of uploading files.

Let me first talk about my understanding:

  1. When checking the status of an item, add a pessimistic lock to prevent other requests from reading the status of this item
  2. During the upload process, if there is a failure, return a failure message and end the request
  3. If both are successful, the project status will be rewritten and unlocked, and other requests can continue
0

There are 0 best solutions below