var folders = [];
// Create a reference under which you want to list
var listRef = storageRef.child('path/to/files');
// Find all the prefixes and items.
listRef.listAll().then(function(res) {
res.prefixes.forEach(function(folderRef) {
// All the prefixes under listRef.
folders.push(folderRef);
});
}).catch(function(error) {
// Uh-oh, an error occurred!
});
var selected = []
// Select N=5 at random
for (i=0; i < 5 && folders.length > 0 ; i++){
var index = Math.floor(Math.random() * folders.length)
selected.push(folders[index])
folders.splice(index, 1);
}
Вы можете перечислить файлы / папки внутри пути корзины. Ссылка . И выберите один случайным образом из этого списка.
И аналогично с удалить файлы .