import { Html } from '@elysiajs/html' import { PropsWithChildren } from '@kitajs/html' import { escapeHTML } from 'bun' import { fileTypeFromBuffer } from 'file-type' import hljs from 'highlight.js' import isValidUTF8 from 'utf-8-validate' import { humanFileSize } from './shared' export const filetypes = ["none", "blob"].concat(hljs.listLanguages().sort()) function Template(props: PropsWithChildren<{ css: string }>) { return ( <> {''} ⚡ZBin⚡ {props.children} ) } export function NotFound() { return ( ) } export function Index(hostname: string, withJs: boolean) { let body = ( <> File is being uploaded, please wait {withJs ?
JS version with client-side encryption, for the version without js an with server-side encryption, go here.
:
JS-less version with server-side encryption, for the version with client-side encryption, go to /js.
}
Optional. If empty, will use the uploaded file name. Used for syntax highlighting, if the file is only containing valid UTF-8 characters. Otherwise it will always be stored as a binary blob. Can select blob to force this detection. Optional. If set, file will be deleted after the given number of minutes. Optional. If set, file will be encrypted and requires the given password to open.
If set, file is already encrypted with an algorithm like in the python file available below. Password is ignored in this case.

curl guide

You can use curl to upload and download files
Upload:
curl {hostname}upload \{"\n"}
                    -F file=@/path/to/file \{"\n"}
                    -F filetype="plaintext" \{"\n"}
                    # optional{"\n"}
                    -F filename="file name" \{"\n"}
                    # optional{"\n"}
                    -F delete_in_minutes="60" \{"\n"}
                    # optional{"\n"}
                    -F password="mypassword" \{"\n"}
                    # optional{"\n"}
                    -F encrypted="on"

If you upload an already encrypted file, you should set the encrypted="on" parameter and encrypt it in a compatible way, so the frontend/backend can also decrypt it. You can use this python script to encrypt a file locally: encrypt.py


Download:
curl {hostname}raw/$uuid?ignore_password=true/false \{"\n"}
                    # optional, if encrypted with password{"\n"}
                    --cookie "password=mypassword"

If ignore_password is set to true, then encrypted files can be downloaded directly (in encrypted form) without supplying the password.

) if (withJs) { body = ( <>
JS seems to be disabled, enable it and refesh the page, or go back tohere for the JS-less version.
{body}