How do I create a file object from a local file? I am trying to attach a file in the custom module's directory to every new node created for a content type. How do I create the file object? The following code gives me an error.

$uri1  = file_unmanaged_copy('checklist1.pdf', 'public://checklist1.pdf', FILE_EXISTS_REPLACE);

$file1 = File::Create([
    'uri' =&gt; $uri1,
]);
$file1-&gt;save();


The error I get is the following one:


  The specified file checklist1.pdf could not be moved/copied because no file by that name exists. Please check that you supplied the correct filename.


To add, this code is in the module file inside a hook.
You need to specify the path to your module:

$module_path = drupal_get_path('module', 'module_name');

$uri1  = file_unmanaged_copy("$module_path/checklist1.pdf", 'public://checklist1.pdf', FILE_EXISTS_REPLACE);