MCPcopy Create free account
hub / github.com/BitVM/BitVM / upload_compressed_object

Method upload_compressed_object

bridge/src/client/data_store/sftp.rs:247–266  ·  view source on GitHub ↗
(
        &self,
        file_name: &str,
        contents: &Vec<u8>,
        file_path: Option<&str>,
    )

Source from the content-addressed store, hash-verified

245 }
246
247 async fn upload_compressed_object(
248 &self,
249 file_name: &str,
250 contents: &Vec<u8>,
251 file_path: Option<&str>,
252 ) -> Result<usize, String> {
253 let compressed_data =
254 compress(contents, DEFAULT_COMPRESSION_LEVEL).map_err(err_to_string)?;
255 let size = compressed_data.len();
256
257 println!("Writing data file to {} (size: {})", file_name, size);
258
259 match self
260 .upload_object(file_name, compressed_data.as_slice(), file_path)
261 .await
262 {
263 Ok(_) => Ok(size),
264 Err(err) => Err(format!("Failed to save json file: {}", err)),
265 }
266 }
267}
268
269async fn test_connection(credentials: &SftpCredentials) -> Result<(), String> {

Callers 1

write_compressed_dataMethod · 0.45

Calls 3

lenMethod · 0.80
compressFunction · 0.50
upload_objectMethod · 0.45

Tested by

no test coverage detected