How do I create a Url object from the public file URI?
I believe that the following should do what you need:

Url::fromUri(
  File::load(1)-&gt;url()
);


(I've tested this in a local 8.4.2 installation, and it yields a Url object that can be rendered without an error.)

The functions are admittedly named very misleadingly. Even though ::fromUri() sounds like it should accept the return value of ::getFileUri(), namely public://..., it actually only accepts internal:, base:, entity: and "external" URLs.

So you need to use -&gt;url() to get the external URL of the file, and then pass that to ::fromUri().