Drupal - Get the public path directory
According to realpath API, you can Get it with :
\Drupal::service('file_system')->realpath(file_default_scheme() . "://");
In case you want to get just "sites/default/files" or "sites/your-multisite/files" Then you should use
// Add to the top of the file.
use Drupal\Core\StreamWrapper\PublicStream;
// In your method.
print PublicStream::basePath();