gitoriaLog in with ident

components

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commite4f01768e4f01768antcolony#40: mission references point to the moved missionsmree4f01768/components/file-upload/demo.hl

1.1 KB

  1. // demo.hl — `/file-upload`: the upload on a page. WHERE THE FILE GOES IS THE APP'S DECISION: the component sends the file through
  2. // `emit server saveFile(file)`; this demo keeps it in storage/uploads under a random name (nothing is served back), for one day.
  3. parent '../main.hl'
  4. import FileUpload from './file-upload.hl'
  5. import { writeFile, mkDir, listDir, remove } from 'hl:fs'
  6. import { randomBytes } from 'hl:crypto'
  7. import { now } from 'hl:time'
  8. __title = 'File upload · Hybriel components'
  9. View {
  10. fileUploadDemo {
  11. h1 { "File upload" }
  12. p { class = "muted" "Drop a file on the box, or choose one: its name, size and progress show, then it is listed as uploaded." }
  13. FileUpload { }
  14. p { a { id = "readme" href = "/file-upload/README.md" "README (how to use it)" } }
  15. }
  16. }
  17. on server saveFile(file) {
  18. mkDir('storage/uploads')
  19. writeFile('storage/uploads/' + now() + '-' + randomBytes(6) + '.bin', file.bytes)
  20. for (e of listDir('storage/uploads')) {
  21. let stamp = toNumber(e.name.slice(0, e.name.indexOf('-')))
  22. if (stamp != null && stamp < now() - 86400000) { remove(e.path) }
  23. }
  24. return { name = file.name size = file.size }
  25. }

Branches

Latest commits

  • e4f01768antcolony#40: mission references point to the moved missionsmre
  • d32b44e2antcolony#40: history (LOG.md), worker briefs (missions/) and reports moved here from antcolony, numbered per project; old numbers in antcolony docs/mission-map.mdmre
  • 0fb80b57components: Hybriel master ff51cf46 (re-vendor round)mre
  • 57408b6ecomponents#14: installable app (manifest, service worker, offline index), own iconmre
  • 317bd09fdeploy.sh: back up live storage/.sessions/.env before every deploy (newest 5 kept)mre
  • becbd59bcomponents#13: modal dialog (<dialog> based, focus wrap, backdrop/Esc/x close with reason, scroll lock, footer buttons)mre
  • 367dd19adeploy.sh: never send .git or .gitignore to Byrodinmre
  • 4b4dabe5State of 2026-09-27, before the move to gitoriamre