Trait rhombus::UploadProvider

source ·
pub trait UploadProvider {
    // Required methods
    fn routes(&self) -> Result<Router>;
    async fn upload<S, E>(&self, filename: &str, stream: S) -> Result<String>
       where S: Stream<Item = Result<Bytes, E>> + Send,
             E: Into<BoxError>;
}

Required Methods§

source

fn routes(&self) -> Result<Router>

The router must implement a POST to /upload/:path route which will upload a file. In most cases, this can be achieved by using the route_upload_file function.

let provider_state = Arc::new(self.clone());
let router = Router::new()
    .route("/upload/:path", post(route_upload_file::<Self>))
    .with_state(provider_state);
Ok(router)
source

async fn upload<S, E>(&self, filename: &str, stream: S) -> Result<String>
where S: Stream<Item = Result<Bytes, E>> + Send, E: Into<BoxError>,

Upload a file to the provider given a filename and a stream of bytes.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl UploadProvider for ()

Available on non-crate feature internal only.
source§

fn routes(&self) -> Result<Router>

source§

async fn upload<S, E>(&self, _filename: &str, _stream: S) -> Result<String>
where S: Stream<Item = Result<Bytes, E>> + Send, E: Into<BoxError>,

Implementors§