Add sftp user to www-data group
usermod -a -G www-data sftpuser
Make first directory owned by root
chown root: /path/to/root_directory
Make the others directories owned by sftpuser:www-data
cd /path/to/web_directory && chown -R sftpuser:www-data *
Then set the good directories and files rights
cd /path/to/project_directory
find . -type d -exec chmod 775 {} \;
find . -type f -exec chmod 664 {} \;
Finally add umask to keep www-data group when sftp user upload file or directory
chmod g+s -R *