Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

253
Views
AdonisJS how can i store multi images with foreach

I just started learning AdonisJS! i can store one image but now i want to store multi images and i can't find any example on AdonisJS how can i do that.

Now I'm saving image like this

   const imageSchema = schema.create({
      image: schema.file.optional({
        size: '2mb',
        extnames: ['jpg', 'png', 'gif'],
      }),
    })

    const validatedData = await ctx.request.validate({ schema: imageSchema })

    let tourDetailedImages: string | null = null
    const image = ctx.request.file('image')
    if (image) {
      const imageFileName = `tour-detailed-${validatedData.image?.size}.${image.extname}`
      await image.moveToDisk(`./`, {
        visibility: 'public',
        name: imageFileName,
      })
      tourDetailedImages = await Drive.getUrl(imageFileName)
    }
    const newImage: Partial<Image> = {
      ...validatedData,
      image: tourDetailedImages ?? '',
    }

    const storedImages = await Image.create(newImage)

How can i store 10 images in same time ? I think i need foreach here but don't really know how to use it can someone help me with this.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!