File Management
Last updated
Last updated
The File section enables you to view and manage all of the files (images, videos, audio files, and attachments) in your workspace. You can easily see and search the files of your workspace and see the file name, mime type, size, and date it was created.
If a file appears in this section then it is included in the overall media storage of your plan. Files will be represented here in two ways:
Uploading a file directly to the database.
Uploading a file directly to the File page.
Creating Metadata for any type of file in the function stack.
Files do not necessarily need to be added to your database to be a file of your workspace. Creating the metadata of a file through the function stack associates that file with your workspace - even if you do not add it to a record in one of your database tables.
File management is extra useful because files are not automatically removed from media storage. For example, deleting a record in the database that contains an image does not remove that image from media storage. If necessary, you can leverage the file management page to remove unwanted files from media storage.
**Deleting a file on the file management page is permanent. You should only do so if you are absolutely certain that you wish to permanently delete the file.**
Deleting a file on the file management page does not remove any database records associated with the file.
To delete a file:
Use the select box on the left side.
Click the red delete button (trash can icon).
Confirm the action. It cannot be undone so be absolutely sure you wish to delete the file.
When an image is stored in a database table and that record is deleted, the file is still available to anyone who has a direct link to that file. Xano provides a separate function to permanently delete files stored in your media storage.
Please ensure that any APIs utilizing the Delete File Resource function are properly secured. This action is permanent and files deleted are not recoverable.
To delete a file permanently from your Files library, add the Delete File Resource function to your function stack and specify the path to the file. This is not the same as the complete URL to the file.
If your image URL is: https://abcd-1234-zyxw.xano.io/vault/SoykeabM/4T0/7ylaZg../image.png
...your path is /vault/SoykeabM/4T0/7ylaZg../image.png
Deleting a file does not remove references to that file in other places. This includes database tables. It is usually best paired with a function or functions to edit or delete the corresponding records.
Uploading a file directly to the file management page is useful if you wish to add a file to the cloud and create a link for it. Previously, this would require you to add schema to a database table and store the file in the database.
If you are looking for details on uploading files through the API please visit content upload.
Once the file is uploaded, you can click on the file name to preview it, download it, or retrieve the URL reference to it.
Private file storage is available as a premium add-on for our Launch plans, or included with Scale or HIPAA compliance.
All files stored as private files are only accessible through on-demand time sensitive URL generation. This means that all files in your Private Storage are inaccessible until you generate a new URL in your function stack.
To work with private file storage, there are two key components to understand: private file database fields and the Private File: Sign URL function.
To store files in your private files library and have them accessible from your function stacks, you'll need to use a database field that is enabled for private file storage. You can enable this for any of the current file field types. Keep in mind that the file access is defined per field, which means that you can not store both public and private files in the same field.
When private files are enabled for a file storage field, a lock icon is displayed in the field name. You will also notice that private files do not display previews from the database view; this is by design, as the files are not accessible until a new URL is generated.
To generate a signed URL that enables a private file to be accessible, you first need to retrieve the path of the file, which is stored in the database record. In this example, we have queried our files table and this is the expected return for a private image. The main difference here is that on public files, a URL is returned. For private files, no URL is provided.
We can then leverage the Private File: Sign URL function to generate a publicly accessible link to the file. Provide the path as offered from the database record, a TTL (how long in seconds the link should be valid for), and finally a return variable to contain the output of the function
When we run this function, we are returned our new signed URL.