Where is the 'uploads' directory for

I have a directory /var/www/nextcloud/user/uploads/2260247444/ with 1678 files in it from 00000000 to 00001678 all with a size of 9.6MB

I never seen this kind of directory before. Looks like a buffer directory for large upload files. Is that correct? The files in there are over 2 days old. Can these files be deleted without any issues? It’s about 16GB.

The uploads folder directly gets filled when the client is uploading files. When the upload finishes this folder gets cleaned out automatically. If one is absolutely certain that no clients for a particular users are uploading files then it is okay to delete the contents of the uploads folder.

clear. thank you!

Is there any way to clean this up automatically?
I use external storage as a only place to store files and my server has very limited file system capacity. A few big uploads with errors and it is full…

Assuming using Debian or a Debian derivative and depending on where uploads folder is located (think it is located in Nextcloud data folder) one could run the following command via cron as www-data as often as wanted.

rm -Rv /srv/nextcloud/data/*/uploads/*

Hello !!

run the following file on daily bases !!


Clean up upload leftover files

This script will remove older files stuck at upload folder

delete older files than 7 days ! no one is uploading for 7 days !!

find /data//uploads/ -type f -mtime +"$LOG_ROTATION" -exec rm {} ;

note /data should be replaced by your data folder path !!

thanks for this, I started using ansible and created this version to get rid of the leftovers. Replace the paths with the one you want clean up.

  - name: Find Temporary Upload Files/Directories older 7 days from User
      paths: "/nextcloud-data/user/uploads"
      age: 7d
      hidden: true
      recurse: yes
      file_type: any
    register: files_to_delete

  - name: Number of Files/Directories to be deleted
      var: files_to_delete.matched

  - name: Delete Files/Directories
      path: "{{ item.path }}"
      state: absent
    with_items: "{{ files_to_delete.files }}"

For sure not the fasted method, because the ansible module for this is quite slow, but native ansible and therefor I prefer this over CMD.

How long should it take after the end of the upload to get cleaned out? Around 20 minutes after stopping a sync I can still see the files in the uploads directory.

EDIT: I checked 1 day later and it was removed. Maybe triggered by the sync app after successfully uploading the files?