'How to upload whole folder and every file inside using cypress?

I have something like that to take 1 file from the folder and just copy that 5 times. What should i do when i just want to upload everything in the location like 600 files? Can someone help me ? Maybe some loop ?

cy.fixture('DSC03431.JPG', 'base64').then((fileContent) => {
        cy.get('#chooseFilesInput').attachFile({
            fileContent: fileContent.toString(),
            fileName: 'DSC03431.JPG',
            mimeType: 'image/jpg',
            encoding: 'base64',

I want to upload contents of a folder to my application using cypress. I know I can mention the names of the files and cypress will pick them, but since I am not aware of the number of files in the folder or their names, how can I upload otherwise?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source