Flow: files uploaded in specific folder

Hello,

I am looking for a way to process files uploaded in a specific folder using flows.

I do not have the ‘when’ File uploaded to nor the condition File is located as shown here

Running NextCloud 19 (waiting for point release to upgrade)

image

I cannot find those options in the code here and here, so I am wondering if it is possible to archive my goal using other options.

Install one of the available “Flow” apps from the app store, e.g the “Workflow external scripts” app to enhance the Nextcloud functions :wink:

@j-ed hose are installed, if not I coudn’t add a flow :stuck_out_tongue_winking_eye:

See by yourself:

If you click in the “Select a filter” field and choose “File name” and then you click in the “Select a comparator” field and select “equals”, the third field will give you the possibility to enter a regular expression. As an example “/^dummy-.+$/i” is usually shown.
You can try to modify this regular expression so that it fits your needs. To be honest, I’ve personally not yet used it to restrict access to a specific folder, because I’ve running this kind of check in the called script itself.
As far as I remember, an enhancement request already exists to get the described selection added to the flow app.

As 'File is upload" and “File is located” options are shown on the official Nextcloud page about that feature I was wondering what I was missing…

I’m personally not using the files upload flow app, but other ones and all of these allow to select “Folder” as mime type value in a rule. So it might be worth to update your version if you cannot see this option in NC 19.x.

So, for those coming from Google and are scratching their head how to achieve this (like I was).

The flow wanted by the original poster is possible, but you need to use Collaborative Tags (it’s a built-in app)

This is actually described in NC official docs:
https://docs.nextcloud.com/server/stable/admin_manual/file_workflows/automated_tagging.html

According to Flow, the tag(s) of a folder is somehow inheritable to its content, so basically:

  1. Tag the upload folder or any target folder with tag “A” (or whatever name).
  2. Create tag “B” (or whatever name).
  3. Create Flow rule, that if file system tag is “A” AND mime type is not folder, then tag the file as “B”.
  4. Create whatever Flow you need with files tagged as “B”.

No. 3 is important but unfortunately is not mentioned anywhere in the docs. This prevents tagging the top folder with both “A” and “B”. Depending on your use-case, you might not want the top folder to be processed at all (e.g. for time-based deletion).

4 Likes

@WhizzWr: You don’t even need two tags or automated tagging - a single rule is sufficient.

So instead of defining the first rule to automatically set tag B if the file is created in a folder with tag A and then to define a second rule to react on tag B, you can create a rule which directly reacts on tag A on the parent folder.

An example which works for me:

Doesn’t this create a race condition if the OP’s flow triggers before the automated file tagging? That is, the intended behavior is

  1. File is added to directory
  2. Automated file tagging tags it as B
  3. OP’s workflow sees the new file and that it has tag B and runs

but if the timing is wrong, you can have

  1. File is added to director
  2. OP’s flow sees the new file, notes that it is not tagged B, and concludes no action needed
  3. Automated file tagging tags it as B.