MCPcopy Index your code
hub / github.com/endbasic/endbasic / get_file_acls

Method get_file_acls

client/src/cloud.rs:269–303  ·  view source on GitHub ↗
(&mut self, username: &str, filename: &str)

Source from the content-addressed store, hash-verified

267 }
268
269 async fn get_file_acls(&mut self, username: &str, filename: &str) -> io::Result<FileAcls> {
270 let mut headers = self.default_headers();
271 headers.insert("X-EndBASIC-GetContent", "false".parse().unwrap());
272 headers.insert("X-EndBASIC-GetReaders", "true".parse().unwrap());
273 let mut builder = self
274 .client
275 .get(self.make_url(&format!("api/users/{}/files/{}", username, filename)))
276 .headers(headers);
277 if let Some(auth_data) = self.auth_data.borrow().as_ref() {
278 builder = builder.bearer_auth(auth_data.access_token.as_str());
279 }
280 let response = builder.send().await.map_err(reqwest_error_to_io_error)?;
281 match response.status() {
282 StatusCode::OK => {
283 let mut readers = vec![];
284 for h in response.headers().get_all("X-EndBASIC-Reader") {
285 match h.to_str() {
286 Ok(value) => readers.push(value.to_owned()),
287 Err(e) => {
288 return Err(io::Error::new(
289 io::ErrorKind::InvalidData,
290 format!("Server returned invalid reader ACL: {}", e),
291 ));
292 }
293 }
294 }
295
296 let bytes = response.bytes().await.map_err(reqwest_error_to_io_error)?;
297 debug_assert!(bytes.is_empty(), "Did not expect server to return content");
298
299 Ok(FileAcls::default().with_readers(readers))
300 }
301 _ => Err(http_response_to_io_error(response).await),
302 }
303 }
304
305 async fn patch_file_content(
306 &mut self,

Callers 1

get_aclsMethod · 0.45

Calls 10

default_headersMethod · 0.80
make_urlMethod · 0.80
as_strMethod · 0.80
pushMethod · 0.80
bytesMethod · 0.80
with_readersMethod · 0.80
insertMethod · 0.45
parseMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected