简体   繁体   中英

When I want to upload image in windows os with adonis js I found this problem how can I solved this

EBUSY: resource busy or locked, copyfile 'C:\Users\user\AppData\Local\Temp\ab-4da7f2e2-3f04-4c93-a453-0a71e1304435.tmp' -> 'F:\nipu\eCommerce\public\images\books\1575106014388.jpeg'

my code is here.....

    const coverImages = request.file('cover_images', {
    types: ['image'],
    size: '2mb'
  })

  const uploadFolder = Helpers.publicPath('/images/books')
  const filePaths = [];

  if(coverImages !== null && coverImages.files.length === 3 ){
    //Temporary
      //filePaths.push(`images/books/default.jpg`);

      await coverImages.moveAll(uploadFolder, (file) => {

        let newFileName = `${new Date().getTime()}.${file.subtype}`
        let newFilePath = `images/books/${newFileName}`

        filePaths.push(newFilePath)

        return {
          name: newFileName,
          overwrite: true
        }
      })

      if(!coverImages.movedAll()){
        return coverImages.errors()
      }

      const bookCovers = {
        img_1 : filePaths[0],
        img_2 : filePaths[1],
        img_3 : filePaths[2]
      }

      bookData.cover_images = JSON.stringify(bookCovers);

  }

Because Your distination directory F:\nipu\eCommerce\public\images\books\ may not publicly accessible.

If your distination is publicly accessible, Apply this official patch fix to move the file across devices/drives by upgrading the new version.

This issue is already reported and closed Here .

Take a tour of File Upload | Adonis

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM