upload photo from file or postman by image address in my drive

I have a schema like this:

const Person = new mongoose.Schema({
  username: {
    type: String,
    required: [true, "Name is a required field"],
    unique: [true, "Another Person with the same name already exists"],
    trim: true
  },
  friends: [
    {
      name: {
        type: String,
        required: [true, "Every friend must have a name"],
        unique: [true, "Another friend with the same name already exists"],
        trim: true
      },
     photo: String,
     favoriteFood: String
    }
  ],
  createdAt: {
    type: Date,
    default: Date.now()
  }
});

I want to add an image for each friend, but I want to upload the photo from something like postman or a seeder file by adding image address in my hard drive in the request. because I have several friends, I have to make each photo specific for each friend. I want to do something like this in postman body or in a file as a seeder to fill database or add data to it.

{
"username": "aUsername",
"friends": [
   {
     "name": "friend1",
     "photo": "./home/user/photos/photo1.jpg",
     "favoriteFood": "Pizza"
   },
   {
     "name": "friend2",
     "photo": "./home/user/photos/photo2.jpg",
     "favoriteFood": "Sushi"
   },   
   {
     "name": "friend3",
     "photo": "./home/user/photos/photo3.jpg",
     "favoriteFood": "Hamburger"
   }
    ]
}

how can I create this feature in the backend?

thanks.

118 thoughts on “upload photo from file or postman by image address in my drive”

  1. Pingback: sildenafil 20mg
  2. Pingback: viagra cost
  3. Pingback: otc viagra
  4. Pingback: cialis for sale
  5. Pingback: female viagra
  6. Pingback: sildenafil 20 mg
  7. Pingback: sildenafil 50mg
  8. Pingback: cialis canada
  9. Pingback: sildenafil gel
  10. Pingback: viagraherse
  11. Pingback: cialis for women
  12. Pingback: sildenafil online
  13. Pingback: cheap viagra

Leave a Comment