Access/Share Nextcloud Data Folder Through Samba Server

Well there is not really an elegant way to achieve what you want…

  1. The file copy operation must be performed by a user who has write permissions on the Nextcloud Data folder
  2. After you made any changes directly in the Nextcloud Data Folder, you have to run occ-files scan.
  3. For security reasons, I would not recommend to share your Nextcloud Data Folder via SAMBA and / or mount it permanently on your PC.

So if you you absolutely have to copy the files directly to the Nextcloud Data Folder, here’s what I would do:

Create a user on the server and add that user to the www-data group:

adduser <username>
usermod -a -G www-data <username>

Use a tool like WinSCP or Filezilla to connect to your server with the previously created user and upload the files to the Nextcloud Data Folder…

After you uploaded the files, run the following commands on the server:

sudo -u www-data php /path/to/nextcloud/occ files:scan --all
chown -R www-data:www-data /var/nextcloud-data
find /path/to/nextcloud-data/ -type d -exec chmod 750 {} \;
find /path/to/nextcloud-data/ -type f -exec chmod 640 {} \;