import { ListObjectsResult } from "../../types/mod.ts";
export function objectList(result: ListObjectsResult) {
return `
${result.prefixes.map(prefix => `
`).join("")}
${result.objects.map(obj => `
📄 ${obj.key}
${formatSize(obj.size)}
${formatDate(obj.lastModified)}
⬇️ Download
`).join("")}
`;
}
function formatSize(bytes: number): string {
const units = ['B', 'KB', 'MB', 'GB', 'TB'];
let size = bytes;
let unit = 0;
while (size >= 1024 && unit < units.length - 1) {
size /= 1024;
unit++;
}
return `${size.toFixed(1)} ${units[unit]}`;
}
function formatDate(date: Date): string {
return date.toLocaleDateString();
}