feat: 콘텐츠 수정 작업
This commit is contained in:
@@ -28,6 +28,10 @@ export const createColumns = (
|
||||
{
|
||||
accessorKey: "atflFlieSz",
|
||||
header: "파일크기",
|
||||
cell: ({ row }) => {
|
||||
const size = row.getValue("atflFlieSz");
|
||||
return size ? formatFileSize(Number(size)) : "0 Bytes";
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
@@ -60,3 +64,14 @@ export const createColumns = (
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
const formatFileSize = (bytes: number): string => {
|
||||
console.log("bytes: ", bytes);
|
||||
if (bytes === 0) return "0 Bytes";
|
||||
|
||||
const k = 1024;
|
||||
const sizes = ["Bytes", "KB", "MB", "GB", "TB"];
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||
|
||||
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(2))} ${sizes[i]}`;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user