morph 0.1.0
Asynchronous bridge between GUI thread and business models
Loading...
Searching...
No Matches
morph::ui::FileTransfer Class Reference

The client of the file side channel (files/1, spec 6 §18): uploads and downloads through ui-file, one chunk of at most kMaxFileChunkBytes in flight at a time, reporting progress after each. More...

#include <service_client.hpp>

Public Member Functions

 FileTransfer (Exchange exchange, ::morph::session::Context session)
 A transfer over exchange, its requests carrying session.
void upload (FileInfo info, std::string bytes, std::string model, std::string action, std::function< void(double)> progress, std::function< void(std::expected< std::string, std::string >)> done) const
 Uploads a file, authorised as the mutation that will reference it.
void download (std::string ref, std::function< void(double)> progress, std::function< void(std::expected< DownloadedFile, std::string >)> done) const
 Downloads a file by its reference.

Detailed Description

The client of the file side channel (files/1, spec 6 §18): uploads and downloads through ui-file, one chunk of at most kMaxFileChunkBytes in flight at a time, reporting progress after each.

What it moves is bytes: reading the file the user picked is the platform's, and an application's InterpreterHost::upload reads it and hands the bytes here.

Definition at line 755 of file service_client.hpp.

Constructor & Destructor Documentation

◆ FileTransfer()

morph::ui::FileTransfer::FileTransfer ( Exchange exchange,
::morph::session::Context session )
inline

A transfer over exchange, its requests carrying session.

Parameters
exchangeThe transport.
sessionThe session every request carries.
Exceptions
std::invalid_argumentfor an empty exchange.

Definition at line 761 of file service_client.hpp.

Member Function Documentation

◆ upload()

void morph::ui::FileTransfer::upload ( FileInfo info,
std::string bytes,
std::string model,
std::string action,
std::function< void(double)> progress,
std::function< void(std::expected< std::string, std::string >)> done ) const
inline

Uploads a file, authorised as the mutation that will reference it.

Parameters
infoIts name, type and size; size is taken from bytes.
bytesThe file.
modelThe model type of the mutation that will reference it.
actionThat mutation's action.
progressCalled with 0 to 1 after each chunk; may be empty.
doneCalled once with the file's reference, or why the upload failed.

Definition at line 775 of file service_client.hpp.

◆ download()

void morph::ui::FileTransfer::download ( std::string ref,
std::function< void(double)> progress,
std::function< void(std::expected< DownloadedFile, std::string >)> done ) const
inline

Downloads a file by its reference.

Parameters
refThe reference a reply carried.
progressCalled with 0 to 1 after each chunk; may be empty.
doneCalled once with the file, or why the download failed.

Definition at line 804 of file service_client.hpp.


The documentation for this class was generated from the following file: