pub enum File {
External(ExternalFile),
Uploaded(UploadedFile),
}
Expand description
Note: The Notion API does not support file uploads.
Therefore, for creating or updating, you are only allowed to
specify an external URL using the ExternalFile
variant of the enum.
https://developers.notion.com/reference/file-object
§File
File objects contain data about a file that is uploaded to Notion, or data about an external file that is linked to in Notion.
When a link to an external file is set, it becomes an object like the one shown below.
{
"name": "https://www.notion.so/images/favicon.ico",
"type": "external",
"external": {
"url": "https://www.notion.so/images/favicon.ico"
}
}
When a file is uploaded to Notion, it becomes an object as shown below.
{
"name": "Project Alpha blueprint",
"type": "file",
"file": {
"url": "https://prod-files-secure.s3.us-west-2.amazonaws.com/daa95f86-2d56-4e18-be3b-16d81b31dc0d",
"expiry_time": "2024-04-04T10:45:54.308Z"
}
}
Variants§
External(ExternalFile)
Uploaded(UploadedFile)
Implementations§
Source§impl File
impl File
Sourcepub fn get_url(&self) -> String
pub fn get_url(&self) -> String
This utility returns the URL regardless of whether the File variant is External or Uploaded. (You can retrieve the URL without having to check the variant).
Sourcepub fn name<T>(self, name: T) -> Self
pub fn name<T>(self, name: T) -> Self
This function can only be used if the File variant is External. If the File variant is Uploaded, it returns Self without changing the value.