@db-state/vue-files
v0.0.11
Published
Vue client file upload/download module for db-state over the same WebSocket.
Maintainers
Readme
@db-state/vue-files
Vue-клиент для upload/download файлов поверх @db-state/vue.
Он использует существующий db-state WebSocket и автоматически регистрирует
state.file, если таблица еще не подключена.
import { createFileClient } from "@db-state/vue-files"
const files = createFileClient(state)
const uploaded = await files.upload(file, {
policy: { mode: "registered" },
onProgress: ({ loaded, total, percent }) => {}
})
await state.message.add({
text,
file: [uploaded.token]
}, "message-form")
const blob = await files.download(uploaded.token, {
onProgress: ({ loaded, total, percent }) => {}
})
files.url(uploaded.token) // /f/<token>Progress передачи файлов идет через onProgress. Он специально отделен от
state.getKeyRef(key), который остается loading/helper-объектом для обычных
db-state чтений и записей.
Полная документация: docs/ru/files.md.
