Skip to content

Instantly share code, notes, and snippets.

@markdon
Created January 15, 2019 05:02
Show Gist options
  • Save markdon/a8b41e7489c807ff72778ae0a237c694 to your computer and use it in GitHub Desktop.
Save markdon/a8b41e7489c807ff72778ae0a237c694 to your computer and use it in GitHub Desktop.
(function deleteFiles(){
const communityId = /communityUuid=([a-f0-9-]+)/.exec(window.location.href)[1];
fetch(`https://devconn6.internal.isw.net.au/files/form/api/communitylibrary/${communityId}/feed?ps=500`).then((response)=>{
response.text().then((text)=>{
const parser = new DOMParser();
const xml = parser.parseFromString(text, 'application/xml');
const ids = [];
for(let el of xml.querySelectorAll('entry uuid'))
ids.push(el.textContent);
ids.forEach(id=>{
fetch(`/files/basic/api/document/${id}/entry?purge=true&deleteResponses=true`, {method:"DELETE"}).then(response=>response.text().then(resText=>console.log(response, resText)));
});
});
});
fetch(`https://devconn6.internal.isw.net.au/files/form/api/communitycollection/${communityId}/feed?page=1&pageSize=500&category=collection&type=all`).then((response)=>{
response.text().then((text)=>{
const parser = new DOMParser();
const xml = parser.parseFromString(text, 'application/xml');
console.log(xml);
const ids = [];
for(let el of xml.querySelectorAll('entry uuid'))
ids.push(el.textContent);
ids.forEach(id=>{
fetch(` /files/basic/api/collection/${id}/entry?purge=true&deleteResponses=true`, {method:"DELETE"}).then(response=>response.text().then(resText=>console.log(response, resText)));
});
});
});
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment