Struct shadow_drive_sdk::models::ShadowFile
source · Expand description
ShadowFile is the combination of a file name and a Payload.
Fields§
§name: String§data: PayloadImplementations§
source§impl ShadowFile
impl ShadowFile
sourcepub fn name(&self) -> &str
pub fn name(&self) -> &str
Examples found in repository?
src/client/edit_file.rs (line 46)
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
pub async fn edit_file(
&self,
storage_account_key: &Pubkey,
data: ShadowFile,
) -> ShadowDriveResult<ShadowUploadResponse> {
let message_to_sign = edit_message(storage_account_key, data.name(), &data.sha256().await?);
let signature = self
.wallet
.sign_message(message_to_sign.as_bytes())
.to_string();
let form = Form::new()
.part("file", data.into_form_part().await?)
.part("signer", Part::text(self.wallet.pubkey().to_string()))
.part("message", Part::text(signature))
.part(
"storage_account",
Part::text(storage_account_key.to_string()),
);
let response = self
.http_client
.post(format!("{}/upload", SHDW_DRIVE_ENDPOINT))
.multipart(form)
.send()
.await?;
if !response.status().is_success() {
return Err(Error::ShadowDriveServerError {
status: response.status().as_u16(),
message: response.json::<Value>().await?,
});
}
let response = response.json::<ShadowUploadResponse>().await?;
Ok(response)
}