Generate image URL from FID I have a custom form in Drupal 8, which has a image upload field. I am storing the file ID of that uploaded image. Now I need to generate the URL of that image.

How can I achieve this?
Get the image file src (url) 

$fid = 1;//The file ID   
$file = \Drupal\file\Entity\File::load($fid);
$path = $file-&gt;getFileUri();


OR

$path = 'public://images/image.jpg';
$url = \Drupal\image\Entity\ImageStyle::load('medium')-&gt;buildUrl($file-&gt;getFileUri());