Created
June 3, 2019 21:31
-
-
Save tcelestino/4e8a5da3175470f1dae23c0281b6457b to your computer and use it in GitHub Desktop.
remove files in images directory at Akamai NetStorage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const deleteImagesFolder = () => { | |
ns.dir('/cpCode/front-app-home/images', (error, res, body) => { | |
if (error) { | |
throw new Error(`Error, ${error.message}`); | |
} | |
if (body.stat !== undefined) { | |
const { file: files } = body.stat; | |
files.forEach(file => { | |
if (file.type === 'file') { | |
ns.delete( | |
`/690579/front-app-home/images/${file.name}`, | |
(errorFile, resFile, bodyFile) => { | |
console.log(bodyFile); | |
} | |
); | |
} else { | |
ns.dir( | |
`/690579/front-app-home/images/${file.name}`, | |
(errorFolders, resFolders, bodyFolders) => { | |
const { | |
attribs: { directory }, | |
file: filesFolders, | |
} = bodyFolders.stat; | |
filesFolders.forEach(fileFolder => { | |
if (fileFolder.type === 'file') { | |
console.log(`${directory}/${fileFolder.name}`); | |
ns.delete( | |
`${directory}/${fileFolder.name}`, | |
(errorMoreFile, resMoreFile, bodyMoreFile) => { | |
console.log(bodyMoreFile); | |
} | |
); | |
} | |
}); | |
} | |
); | |
} | |
}); | |
} | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment