Function edjx::storage::put_streaming

source ·
pub fn put_streaming<B, FN, A>(
    bucket_id: B,
    file_name: FN,
    properties: A
) -> Result<(StorageResponsePending, WriteStream), StorageError>where
    B: AsRef<str>,
    FN: AsRef<str>,
    A: AsRef<str>,
Expand description

Starts streaming a file to the EDJX Object Store. This method returns a WriteStream and a StorageResponsePending. The WriteStream is used to stream data, the StorageResponsePending is a placeholder to retreive StorageResponse.

Error Response

This method returns an error response of kind StorageError

Example

use edjx::{storage, StorageResponse, BaseStream};

let file_name = "example.txt";
let bucket_id = "af66ad83-e55b-4a71-a7d5-6ec3199e42e9";
let properties = "Cache-Control=true,Type=text";

let (storage_resp_pending, mut write_stream) = storage::put_streaming(&bucket_id, &file_name, &properties).unwrap();

write_stream.write_chunk_text("A chunk of text").unwrap();
write_stream.write_chunk_binary(Vec::from("A chunk of binary data")).unwrap();
write_stream.close().unwrap();

let storage_res: StorageResponse = storage_resp_pending.get_storage_response().unwrap();