Add retrieval of its bytes to the file struct

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/1/head
trivernis 3 years ago
parent a73e7de532
commit d3b4093f93
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -1,5 +1,5 @@
use crate::endpoints::adding_tags::{AddTagsRequestBuilder, TagAction};
use crate::endpoints::common::{FileIdentifier, FileMetadataInfo};
use crate::endpoints::common::{FileIdentifier, FileMetadataInfo, FileRecord};
use crate::error::Result;
use crate::service::ServiceName;
use crate::tag::Tag;
@ -177,4 +177,9 @@ impl HydrusFile {
self.client.add_tags(reqwest.build()).await
}
/// Retrieves the file record bytes
pub async fn retrieve(&self) -> Result<FileRecord> {
self.client.get_file(self.id.clone()).await
}
}

@ -72,3 +72,11 @@ async fn it_modifies_tags() {
.await
.unwrap();
}
#[tokio::test]
async fn it_retrieves_content() {
let file = get_file().await;
let file = file.retrieve().await.unwrap();
assert!(file.bytes.len() > 0) // assuming it exists
}

Loading…
Cancel
Save