Workflow or plugin for deleting files after download

Hello everyone, this is my first post, I hope to be in the right section :grinning:

Yesterday I installed Nextcloud on my Ubuntu Server 20.04, the process run smoothly and I have a working instance of this service.

For a project, I have to implement the following feature: delete an externally shared file AFTER it has been downloaded.

Browsing nextcloud docs i found out about Workflows, and I installed the app called Workflow external scripts (vers. 1.8) since it seems more flexible. Github with readme here: GitHub - nextcloud/workflow_script: Rule based processing of files through specified external scripts

So I tried to create a flow that does something like:
When File is accessed AND file system tag IS sometag RUN script rm %n

This flow above does apparently nothing, so I tried with something easier to check:
When File is renamed RUN script touch /tmp/test.txt

Still nothing happens…
I tried to check logs in nextcloud/data/nextcloud.log, but keeping it open with tail -f i see no new lines.
Browsing the web for answers or helps i found this thread Using Workflow External script to generate searchable PDF

I also tried to create an helper bash script like that but still no luck.

Can I have some working example of some simple workflow? Would be super cool if someone knows if the deleting file after download can be feasible in this way.

Thanks

Here is a long-time feature request:

Did you check the documentation? There is also github.

https://docs.nextcloud.com/server/latest/developer_manual/digging_deeper/flow.html

Why not use the downloadlimit app for this?

https://apps.nextcloud.com/apps/files_downloadlimit

2 Likes

Hey thanks, it works :grinning:

Well actually it does not delete the file from nextcloud, but I think I still should be ok with this. The most important thing was to have a one time download.

@just That feature request has not been implemented, correct? Yes I read that documentation page, but being honest, I still have no clue on how write a working workflow. The Info there seems much different on what I see in the flow panel (at http://my-nextcloud.com/index.php/settings/admin/workflow)

You can try asking for help with your “share then delete” workflow on the community chat. Might be able to find more advice there.

You can also check out the retention app in case it can help you. Here is the documentation

Yes, I’m using the retention app to have a “base” deleting mechanism.
In this way if the shared file is downloaded, it will be automatically removed after x days, while the share link will instantly decay.
Else, if nobody download the file, it still will be deleted after the retention period.