dba/databases  library module
R

Summary

Download resources.
Authors
  • Christian Grün, BaseX Team 2005-23, BSD License
Related documents
ViewDescriptionFormat
xqdocxqDoc xml file from the source modulexml
xqparsexqparse xml file from the source modulexml

Imports

This module is imported by 0 modules. It imports 0 modules.

Variables

None

Functions

4.1 dba:backup-download

Arities: #1R

Signatures
dba:backup-download ( $backup as xs:string ) as item()+
Parameters
  • backup as xs:string
Return
  • item() +
Invoked by 0 functions from 0 modules
    Annotations (2)
    %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:

    PrefixUri
    dbhttp://basex.org/modules/db
    dbadba/databases 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
    filehttp://expath.org/ns/file
    resthttp://exquery.org/ns/restxq
    webhttp://basex.org/modules/web
    xshttp://www.w3.org/2001/XMLSchema

    6 RestXQ

    Paths defined 1.

    PathMethodFunction
    /dba/backup/{$backup}GETdba:backup-download#1

    Source Code

    (:~
     : Download resources.
     :
     : @author Christian Grün, BaseX Team 2005-23, BSD License
     :)
    module namespace dba = 'dba/databases';
    
    (:~
     : Downloads a database backup.
     : @param  $backup  name of backup file (ignored by the server)
     : @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)
      )
    };