dba/databases
library moduleR
Summary
Download resources.
- Tags
Author: Christian Grün, BaseX Team 2005-21, BSD License
__source : databases/resources/backup-download.xqm
Imports
This module is imported by 0 modules. It imports 0 modules.
Variables
None
Functions
4.1 dba:backup-download
Arities: dba:backup-download#1R
dba:backup-download
(
$backup
as
xs:string
)
as
item() +
- backup
as
xs:string
name of backup file (ignored)
item() +
binary data
Invokes 4 functions from 3 modules
- {http://basex.org/modules/db}option#1
- {http://basex.org/modules/web}response-header#2
- {http://expath.org/ns/file}read-binary#1
- {http://expath.org/ns/file}size#1
Invoked by 0 functions from 0 modules
Annotations
%rest:GET | () |
%rest:path | ('/dba/backup/{$backup}') |
Source ( 12 lines)
function dba:backup-download(
$backup as xs:string
) as item()+ {
let $path := db:option('dbpath') || '/' || $backup
return (
web:response-header(
map { 'media-type': 'application/octet-stream' },
map { 'Content-Length': file:size($path) }
),
file:read-binary($path)
)
}
Namespaces
The following namespaces are defined:
Prefix | Uri |
---|---|
dba | dba/databases 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
rest | http://exquery.org/ns/restxq |
Source Code
(:~
: Download resources.
:
: @author Christian Grün, BaseX Team 2005-21, BSD License
:)
module namespace dba = 'dba/databases';
(:~
: Downloads a database backup.
: @param $backup name of backup file (ignored)
: @return binary data
:)
declare
%rest:GET
%rest:path('/dba/backup/{$backup}')
function dba:backup-download(
$backup as xs:string
) as item()+ {
let $path := db:option('dbpath') || '/' || $backup
return (
web:response-header(
map { 'media-type': 'application/octet-stream' },
map { 'Content-Length': file:size($path) }
),
file:read-binary($path)
)
};