Skip to content

Instantly share code, notes, and snippets.

@tcelestino
Created June 3, 2019 21:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tcelestino/4e8a5da3175470f1dae23c0281b6457b to your computer and use it in GitHub Desktop.
Save tcelestino/4e8a5da3175470f1dae23c0281b6457b to your computer and use it in GitHub Desktop.
remove files in images directory at Akamai NetStorage
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