#✅ Transfer files from folder to folder using Flows

31 messages · Page 1 of 1 (latest)

fiery grove
#

Good day, I would like to ask the possibility of transferring files from folder to folder using our Flows. Thanks in advance.

bold fiberBOT
#

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.)

gusty tiger
#

Folders are just a relation so a regular update to files changing the folder field to the new folder ID should do it

fiery grove
#

Hi Tim, can you elaborate more on how to do this?

gusty tiger
#

something like

fiery grove
#

directus_files collection is available for what role?

gusty tiger
#

Core collections are not in the dropdown but you can bypass that

fiery grove
#

Okay, I tried it and gives me this response

{
"name": "DirectusError",
"message": "You don't have permission to access this."
}

gusty tiger
#

Did you set the permissions correctly? And/Or a valid File ID

fiery grove
#

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

gusty tiger
gusty tiger
#

But before complicating things i'd first try it with hardcoded values, else debugging is nightmare

fiery grove
fiery grove
#

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?

gusty tiger
#

$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

fiery grove
#

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?

gusty tiger
#

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)

gusty tiger
fiery grove
#

Okay thanks, let me try to log the operation_key

gusty tiger
#

You can just open the read data operation to check

fiery grove
gusty tiger
#

just the UUID

#

It is a relation from directus_files to directus_folders with the UUID being the related ID 🙂

fiery grove
#

Ow cool, so I need to get the uuid of the current folder too

gusty tiger
#

that should be the current value of the folder field on your file record (before changing it here)

fiery grove
#

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.

bold fiberBOT
#

✅ Transfer files from folder to folder using Flows