There is a front on Angular and back on express. At the front, the user creates an article. This article has fields with different data types. The article will be sent to the server conditionally in the form of such an object:

{ name: 'Название статьи', preText: 'Предисловие', text: 'Основной текст', isActive: true, count: 15, mainImg: ???, pretextImg: ???, otherImg: ??? } 

The question is that there are images in this article. They may be different count and in different places. How to send such an article to the back? Can I send pictures inside this object, or send them a separate request? If only a separate, then how to understand what image from where?

    1 answer 1

    1. First, send pictures to save.
      1. The server saves the image to disk.
      2. The server adds an entry to the database (id, path to the image).
      3. The server returns client id images from the database.
    2. After sending all the pictures to the data on the article, the client enters the id of these pictures from the database (those that the server returned when sending pictures to the client).
    3. The client sends a request to save the article to the server.
    • Many thanks for such an accessible explanation. Only one thing remains unclear - how to identify photos on the server. By name? The client sends 10 photos from different places of the article. The server saves them and returns to the client IDs. But the server should return not just an array of IT employees, but with some keys (mainImg, preview, etc.) - aim777
    • one
      When sending pictures to save, you can add some extra. pass the parameter and return it later. - Suvitruf