#✅ Transfer files from folder to folder using Flows
31 messages · Page 1 of 1 (latest)
Thanks for posting! This is a community powered server, so you may or may not get an answer based on available help and expertise. To increase your chances of somebody being able to help you, please help us help you making sure you:
- Adding an explanation of exactly what you're trying to achieve.
- Adding any and all related code or previous attempts.
- Describing the exact issue or error you are facing.
- Posting any screenshots if applicable.
- Reading through https://stackoverflow.com/help/how-to-ask.
When you're done with this thread, please close it. Thanks! ✨
(If you have a support agreement and need help, please contact the core team via email.)
Folders are just a relation so a regular update to files changing the folder field to the new folder ID should do it
Hi Tim, can you elaborate more on how to do this?
something like
directus_files collection is available for what role?
Core collections are not in the dropdown but you can bypass that
Okay, I tried it and gives me this response
{
"name": "DirectusError",
"message": "You don't have permission to access this."
}
Did you set the permissions correctly? And/Or a valid File ID
If I have file_uploaded in my model I will only add it in tag as {{$last.file_uploaded}} right?
I'm currently running as administrator
then permissions should be fine as long as you didnt select "public permissions". then it is probably an invalid file ID you're trying to update
If that value exists on your data chain or more specifically on the data returned from your last operation then thats correct. But thats something you should know as you built the flow 🙈
But before complicating things i'd first try it with hardcoded values, else debugging is nightmare
Will do this first and get back to you
I see, since $last only returns new data that is changed. I need to do read data first to get the file id of the changed data. Is this the correct approach?
$last returns whatever the last operation returns, if you're watching update event then yeah $trigger only has the changed fields so you will need to fetch any fields required in most cases
Read Data sends it to new payload to go to the next operation right?
What key should I use to access the payload sent by Read Data?
operation data gets added to the global "state object", so an opation has access to any data from previous operations (where last changes depending on where you are in the flow)
the key of the operation (is configurable) example is top right of my screenshot
Okay thanks, let me try to log the operation_key
You can just open the read data operation to check
Should this be folder + uuid like below?
{ "folder": "folder_name/uuid"}
just the UUID
It is a relation from directus_files to directus_folders with the UUID being the related ID 🙂
Ow cool, so I need to get the uuid of the current folder too
that should be the current value of the folder field on your file record (before changing it here)
Thanks for you support. Was able to do it by getting the UUID of the file and transferring it using {"folder": "<folder_name_uuid"}
Grateful for your patience. Hope you have a nice day.
✅ Transfer files from folder to folder using Flows