To get the details of a file you can use the Get File API endpoint.You can also use this endpoint to retrieve a new temporary pre-signed URL to download a file if the previous pre-signed URL has already expired.
If you need to filter files by tags, pass in the tags parameter, which is an object containing tags as key-value pairs. This will only return files that include all the tags (and corresponding values) that you specify.
The List Files API endpoint will return by default the 20 most recent files your bot has. If you need to list older files you can use the nextToken property returned in the API response to retrieve the next page (if any) of files. The nextToken will be included for each page if there are files remaining to be listed.For example:
let res = await client.listFiles({})const files = res.files// You can put this in a loop to retrieve all the files if neededif (res.meta.nextToken) { res = await client.listFiles({ nextToken: res.meta.nextToken }) files.push(...res.files)}
Only the tags and access policies of a file can be updated.Here’s an example of how to update the access policies and tags of a file using the Botpress Client:
const response = await client.updateFileMetadata({ id: 'file_01K86HD0D5T3HFCGBEKQJFNKAD', accessPolicies: ['integrations'], // This value will replace the existing access policies of the file. tags: { // This acts as a "patch" or partial update, so only the tags specified here will be updated, the rest will remain unchanged. If you need to delete an existing tag, you can set it to a `null` value. category: 'Support', // This tag will be updated. knowledgeBaseName: null, // This tag will be deleted. subcategory: 'Technical', // This tag will be added. // Any other tags not specified here will remain unchanged. },})const updatedFile = response.file
If you need to update the content of a file, you can create a new file with the updated content and then delete the old file. The file ID will change in this case.