pub struct FilesResource<'a> { /* private fields */ }Expand description
client.files()
Implementations§
Source§impl<'a> FilesResource<'a>
impl<'a> FilesResource<'a>
Sourcepub fn create(
&self,
domain_type: impl Display,
domain_identifier: impl Display,
files: &[Upload],
) -> Result<Vec<FileUploadResult>>
pub fn create( &self, domain_type: impl Display, domain_identifier: impl Display, files: &[Upload], ) -> Result<Vec<FileUploadResult>>
Upload files
POST /files/{domainType}/{domainIdentifier}
Uploads files to a domain object. Requires update permission. The attachment category controls file multiplicity, image dimensions and category-specific processing.
Use Self::create_with to pass query parameters.
§Example
let file = Upload::from_path("gemeindebrief.pdf")?;
for file in client.files().create(serde_json::json!("agenda_PRO_PRESENTER_6"), "42", &[file])? {
println!("{}", file.name);
}Sourcepub fn create_with(
&self,
domain_type: impl Display,
domain_identifier: impl Display,
files: &[Upload],
form: &PostFilesDomainTypeDomainIdentifierForm,
) -> Result<Vec<FileUploadResult>>
pub fn create_with( &self, domain_type: impl Display, domain_identifier: impl Display, files: &[Upload], form: &PostFilesDomainTypeDomainIdentifierForm, ) -> Result<Vec<FileUploadResult>>
Upload files
Like Self::create, with form fields.
POST /files/{domainType}/{domainIdentifier}
Uploads files to a domain object. Requires update permission. The attachment category controls file multiplicity, image dimensions and category-specific processing.
Sourcepub fn delete(&self, id: impl Display) -> Result<()>
pub fn delete(&self, id: impl Display) -> Result<()>
Delete a file by ID
DELETE /files/{id}
Deletes one file or URL attachment. Requires update permission for its owning object and runs category-specific delete hooks.
§Example
client.files().delete(1)?;Sourcepub fn delete_for_object(
&self,
domain_type: impl Display,
domain_identifier: impl Display,
) -> Result<()>
pub fn delete_for_object( &self, domain_type: impl Display, domain_identifier: impl Display, ) -> Result<()>
Delete all files for a domain object
DELETE /files/{domainType}/{domainIdentifier}
Deletes every file and URL attachment of the domain object. Requires update permission for the object and runs category-specific delete hooks.
§Example
client.files().delete_for_object(serde_json::json!("agenda_PRO_PRESENTER_6"), "42")?;Sourcepub fn get_meta(&self, id: impl Display) -> Result<CtFile>
pub fn get_meta(&self, id: impl Display) -> Result<CtFile>
Get file metadata by ID
GET /files/{id}/meta
Returns normalized metadata for a file or URL attachment. Requires view permission for the file. Anonymous access depends on the attachment category.
§Example
let meta = client.files().get_meta(1)?;
println!("{}", meta.name);Sourcepub fn get_metadata(&self, file_id: impl Display) -> Result<LegacyFileMetadata>
👎Deprecated: GET /files/{fileId}/metadata is deprecated in the ChurchTools API. Use GET /files/{id}/meta for normalized file metadata.
pub fn get_metadata(&self, file_id: impl Display) -> Result<LegacyFileMetadata>
GET /files/{fileId}/metadata is deprecated in the ChurchTools API. Use GET /files/{id}/meta for normalized file metadata.
Get legacy file metadata
GET /files/{fileId}/metadata
Returns the raw file database record without a response envelope. Use GET /files/{id}/meta for normalized file metadata.
§Example
let metadata = client.files().get_metadata(42)?;
println!("{}", metadata.id);Sourcepub fn link(
&self,
domain_type: impl Display,
domain_identifier: impl Display,
body: &FileLinkCreate,
) -> Result<CtFile>
pub fn link( &self, domain_type: impl Display, domain_identifier: impl Display, body: &FileLinkCreate, ) -> Result<CtFile>
Add a link attachment
POST /files/{domainType}/{domainIdentifier}/link
Creates a URL attachment without fetching its target. Requires update permission and runs the selected category’s file-save hooks.
§Example
let body = models::FileLinkCreate {
url: "https://example.org/service-notes".into(),
..Default::default()
};
let file = client.files().link(serde_json::json!("agenda_PRO_PRESENTER_6"), "42", &body)?;
println!("{}", file.name);Sourcepub fn list(
&self,
domain_type: impl Display,
domain_identifier: impl Display,
) -> Result<Vec<CtFile>>
pub fn list( &self, domain_type: impl Display, domain_identifier: impl Display, ) -> Result<Vec<CtFile>>
Get all files for a specific domain object
GET /files/{domainType}/{domainIdentifier}
Returns metadata for files and URL attachments of one domain object. Files hidden by view permissions or showOnlyWhenEditable are omitted. Anonymous access depends on the selected attachment category.
§Example
for file in client.files().list(serde_json::json!("agenda_PRO_PRESENTER_6"), "42")? {
println!("{}", file.name);
}Sourcepub fn list_for_type(&self, domain_type: impl Display) -> Result<Value>
pub fn list_for_type(&self, domain_type: impl Display) -> Result<Value>
Get all files for a domain type
GET /files/{domainType}
Returns file and URL-attachment metadata for one attachment category. Files hidden by view permissions or showOnlyWhenEditable are omitted.
§Example
let result = client.files().list_for_type(serde_json::json!("agenda_PRO_PRESENTER_6"))?;
println!("{:?}", result);Sourcepub fn patch(&self, id: impl Display, body: &FileUpdate) -> Result<()>
pub fn patch(&self, id: impl Display, body: &FileUpdate) -> Result<()>
Update file metadata by ID
PATCH /files/{id}
Updates a file’s display metadata and optionally copies it to another attachment context. Updating requires source update permission; copying requires source view permission and target update permission.
§Example
let body = models::FileUpdate {
name: Some(Some("Service notes.pdf".into())),
..Default::default()
};
client.files().patch(1, &body)?;Sourcepub fn update_for_object(
&self,
domain_type: impl Display,
domain_identifier: impl Display,
body: &FileDomainUpdate,
) -> Result<()>
pub fn update_for_object( &self, domain_type: impl Display, domain_identifier: impl Display, body: &FileDomainUpdate, ) -> Result<()>
Update files for a domain object
PATCH /files/{domainType}/{domainIdentifier}
Updates the display name and sort key of every attachment of the domain object. Requires update permission and runs category-specific metadata hooks for each affected file.
§Example
let body = models::FileDomainUpdate {
name: Some(Some("Service notes.pdf".into())),
..Default::default()
};
client.files().update_for_object(serde_json::json!("agenda_PRO_PRESENTER_6"), "42", &body)?;