2021-11-28 15:19:00 +01:00
|
|
|
<script context="module">
|
|
|
|
export const file_struct = {
|
|
|
|
id: "",
|
|
|
|
name: "",
|
|
|
|
size: 0,
|
|
|
|
bandwidth_used: 0,
|
|
|
|
bandwidth_used_paid: 0,
|
|
|
|
downloads: 0,
|
|
|
|
views: 0,
|
|
|
|
mime_type: "",
|
|
|
|
availability: "",
|
|
|
|
abuse_type: "",
|
2022-01-27 19:56:44 +01:00
|
|
|
hash_sha256: "",
|
2021-11-28 15:19:00 +01:00
|
|
|
show_ads: false,
|
|
|
|
can_edit: false,
|
|
|
|
get_href: "",
|
|
|
|
info_href: "",
|
|
|
|
download_href: "",
|
|
|
|
icon_href: "",
|
|
|
|
}
|
|
|
|
export const list_struct = {
|
|
|
|
id: "",
|
|
|
|
title: "",
|
|
|
|
files: [],
|
|
|
|
download_href: "",
|
|
|
|
info_href: "",
|
|
|
|
can_edit: false,
|
|
|
|
}
|
|
|
|
|
|
|
|
export const file_set_href = file => {
|
|
|
|
file.get_href = window.api_endpoint+"/file/"+file.id
|
|
|
|
file.info_href = window.api_endpoint+"/file/"+file.id+"/info"
|
|
|
|
file.download_href = window.api_endpoint+"/file/"+file.id+"?download"
|
|
|
|
file.icon_href = window.api_endpoint+"/file/"+file.id+"/thumbnail"
|
|
|
|
file.timeseries_href = window.api_endpoint+"/file/"+file.id+"/timeseries"
|
|
|
|
}
|
|
|
|
export const file_type = file => {
|
2022-01-11 18:53:01 +01:00
|
|
|
if (file.mime_type === "application/bittorrent" || file.mime_type === "application/x-bittorrent") {
|
|
|
|
return "torrent"
|
|
|
|
} else if (file.mime_type.startsWith("image")) {
|
2021-11-28 15:19:00 +01:00
|
|
|
return "image"
|
|
|
|
} else if (
|
|
|
|
file.mime_type.startsWith("video") ||
|
|
|
|
file.mime_type === "application/matroska" ||
|
|
|
|
file.mime_type === "application/x-matroska"
|
|
|
|
) {
|
|
|
|
return "video"
|
|
|
|
} else if (
|
|
|
|
file.mime_type.startsWith("audio") ||
|
|
|
|
file.mime_type === "application/ogg" ||
|
|
|
|
file.name.endsWith(".mp3")
|
|
|
|
) {
|
|
|
|
return "audio"
|
|
|
|
} else if (
|
|
|
|
file.mime_type === "application/pdf" ||
|
|
|
|
file.mime_type === "application/x-pdf"
|
|
|
|
) {
|
|
|
|
return "pdf"
|
|
|
|
} else if (
|
|
|
|
file.mime_type.startsWith("text")
|
|
|
|
) {
|
|
|
|
return "text"
|
|
|
|
} else {
|
|
|
|
return "file"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|