Skip to content

Latest commit

 

History

History
24 lines (21 loc) · 1.24 KB

README.md

File metadata and controls

24 lines (21 loc) · 1.24 KB

Back-end for Birds of Aotearoa

Screenshot 2023-11-27 at 3 46 23 PM Screenshot 2023-11-27 at 3 46 35 PM

Running npm

the file can be run into asgn2-starter-main code and then running "npm run start"

  • the other files are just remaining from

Refernces:

Chat gpt assisted in generating code for creating a counter based logic in the case that there were uploaded files had the same file name "if (newPhotoName) { let counter = 0; let photoPath = path.join(__dirname, 'public/images', newPhotoName);

  //checking if there is a file conflict 
  while (await fsPromises.access(photoPath).then(() => true).catch(() => false)) {
    counter++;
    const extension = path.extname(newPhotoName);
    const name = path.basename(newPhotoName, extension);
    newPhotoName = `${name}_${counter}${extension}`;
    photoPath = path.join(__dirname, 'public/images', newPhotoName);
  }
  await fsPromises.writeFile(photoPath, file.buffer);
}"