File Drop into different Folders with Size-Restriction

After installing Nextcloud with Ubuntu i sucessfully created a file drop, where anyone can upload files without a Login.

To this topic i have two questions (i tried to solve it by myself, but i didnt find a solution):

  1. I would love to store uploaded Files in seperate Folders. One per Upload… I know i could make a new folder and create a new File Drop for this, but i want to Nexctloud to do it automatically…
    Like: Person A uploads content at monday 08:00 a.m. → Automatically stores in the new folder “filedrop_monday0800”; Person B uploads content at the same time → Automatically stores in new folder “filedrop_monda0800_2”
  2. I want to restrict the size of the uploaded file-bundle to a specific size e.g. 100MB.

Is there a possibilty to get the functionallity i want with nextcloud?

Thanks much for help

I don’t think you can have this with file-drop functionality. but you can perform automated action using Flow/Workflow and move the file to another destination just after upload (and using “external script” you could even create new folders etc…).

Upload limit is harder - I have recipe now but maybe you can trick a solution using fake user with quota little higher than your upload limit and moving the files to folder of another user not affected by this quota…

1 Like

For Flow/Workflow you can read the last entry in this thread. It doesn’t solve your problem. But it would be the first step.

1 Like

Thanks for your help!

I tried to setup things with Flow:
Automated Tagging works well!
But when i tried to trigger a simple Skript, nothing happened. (Simple Trigger is renaming an image file)

Ive got a file /var/www/html/nextcloud/test.sh with the following content:

#!/bin/bash
date >> /var/www/html/nextcloud/test.txt
echo "$1" >> /var/www/html/nextcloud/test.txt

I can execute it with the following command from the ubuntu command line:

sudo -H -u www-data bash -c 'bash /var/www/html/nextcloud/test.sh'

Of course the third line does not give any output! But the date is printed as desired.

My Flow-Command is:

bash /var/www/html/nextcloud/test.sh %n

I also tried without prefixed bash, same result.

So, when i rename a picture, the file /var/www/html/nextcloud/test.txt isnt changed.

But when i rename a picture AND THEN execute the following command on Ubuntu the Skript is running as i wanted:

sudo -u www-data php -f /var/www/html/nextcloud/cron.php

Where is my fault? I want to trigger the Script automatically and not manually…

I could try to execute it with a cronjob from Ubuntu, but i think this would not be the best solution


Second question:
I can move the files with the commands in test.sh:

newFolder=$(date '+%Y_%m_%d_%H_%M')

mkdir /var/www/html/nextcloud/data/$2/files/$newFolder
mv /var/www/html/nextcloud/data/"$1" /var/www/html/nextcloud/data/$2/files/$newFolder/

But the directory just changed on Ubuntu. In nextcloud the file are still in the directory where i uploaded it…
How to fix that?

Fixed the second question with executing the following command:

sudo -u www-data php occ files:scan --all

This command also works inside the skript test.sh, so it must not be executed manually!

You can normally use the parameter user-id.
sudo -u www-data php occ files:scan user-id
Mabe it works in your script and you can minimize the time for execution.
I think user-id is $1 $2 (both users together in one command or two commands).
Maybe only useful if you have many non-involved users you want not scan.

1 Like

The flow command in conbination with cronjob is working: The files are moved into new folders… I can see this on my server…

But in the Nextcloud GUI nothing happend. The changes are just displayed when i execute sudo -u www-data php occ files:scan USERNAME manually or when i execute a bash script with this command inside…
But it seems it does not work directly in the Script triggered with Flow

Also i made a second Cronjob which execute the command above, but it doesnt work too…

Can you post your script (again)? Maybe there is an error in the script.

Script:

#!/bin/bash
newFolder=$(date '+%Y_%m_%d_%H_%M')
mkdir -p /var/www/html/nextcloud/data/$2/files/$newFolder
mv /var/www/html/nextcloud/data/"$1" /var/www/html/nextcloud/data/$2/files/$newFolder/
php occ files:scan $2

Flow command:

/var/www/html/nextcloud/test.sh %n %o

%n is the relative path of the file. In the script it is $1.
%o is the nextcloud username. In the script it is $2.

Cron Command:

*/5  *  *  *  * php -f /var/www/html/nextcloud/cron.php

Result:
The folders are created and the files are moved as desired.
Just the last line of the script doesnt work. Nothing is changed in the GUI of Nextcloud until i execute the last line as user www-data with the following command:

sudo -u www-data php occ files:scan USERNAME

First use full paths

php /var/www/html/nextcloud/occ files:scan $2
2 Likes

That solved the problem :slight_smile:
As always, the solution is very simple :smiley:
Thanks for all your help!

2 Likes