Allow syncing directus_files
I'd like to be able to sync directus_files. I don't need directus-sync to handle syncing the assets themselves, only the table entries. I manage some icon files with predefined names that map to a custom icon library, these are uploaded as images in Directus until Directus has a better system for managing custom icons.
I essentially do a GCS/S3 copy with a glob on SVGs, and I was planning on filtering the synced files based off this hook:
files: {
/**
* @param {Query} query
* @param {DirectusClient} client
*/
onQuery: (query, _client) => {
query.filter = {
...query.filter,
type: { _eq: "image/svg+xml" },
};
return query;
},
}
This is the error I get having defined files in onlyCollections.
"message": "Config file: [onlyCollections,3] Invalid enum value. Expected 'dashboards' | 'flows' | 'folders' | 'operations' | 'panels' | 'permissions' | 'policies' | 'presets' | 'roles' | 'settings' | 'translations', received 'files'",
Please also enable syncing files, leaving the responsibility of the assets themselves to to the user. I believe directus says if it can't find a file in your storage and it let's you upload a file to update the file entry if so.
Really awesome library! I had written some scripts of my own for managing snapshot state and wrote idempotent seeds using the GraphQL API but I found the flow made more sense to just interact with the UI directly and use your utility! Much cleaner flow!
@shadiramadan The sync of file is not supported yet, but it could be achieved once the Seed feature is finished. I'm currently working on it. Thanks for the words
Hey @EdouardDem I would like to check on the status of syncing files from the hdd to the directus assets. Is that a feature you describe to be working on? I would like to use this feature.
Any news? any alternatives to sync files?
❤️
Hi @ulfgebhardt. I'm currently working on it: https://github.com/tractr/directus-sync/tree/132-allow-syncing-directus_files Directus does not allow to create a file without the asset. I have to fix an issue and write some tests for this features. Then I will merge this branch and publish a new release (with others features).
It will be achieved with the seed command, so you can choose which files are synced
Thank you @EdouardDem for your answer and thank you for your work. I solved the problem for now with a shell script, but I am looking forward to your solution!
https://github.com/utopia-os/utopia-map/pull/313/files#diff-82a7d1cfa37787edcd4a59475c951805aa32dc6a46e8a49a93e330cf710bbadf
(once merged the script can be found here backend/directus-config/manual/seed.sh)
Hi. It has been added in the new version: https://github.com/tractr/directus-sync/releases/tag/directus-sync%403.3.0
Sorry, I couldn't find the latest version on the npm registry. https://www.npmjs.com/package/directus-extension-sync?activeTab=versions
BTW, thanks for this awesome extension 😃
Thanks for the words. It's a new version of the CLI : https://www.npmjs.com/package/directus-sync?activeTab=versions