code: protected function determineFilename($originalFilename, array $mediaFileInfo)
      {
          if (is_null($originalFilename) || ! isset($originalFilename) || is_file(sys_get_temp_dir() . '/' . $originalFilename)) {
              //Need to create a unique file name as file either exists or we couldn't determine it.
              //Create temp file in system folder.
              $uniqueFilename = tempnam(sys_get_temp_dir(), 'tg');
              //Add file extension
              rename($uniqueFilename, $uniqueFilename . '.' . $mediaFileInfo['fileextension']);
  
              $mediaFileInfo['filepath'] = $uniqueFilename . '.' . $mediaFileInfo['fileextension'];
  
          } else {
              $mediaFileInfo['filepath'] = sys_get_temp_dir() . '/' . $originalFilename;
          }
  
          return $mediaFileInfo;
      }
docs: Determine if we can use the filename given to us via a URI or do
  we have to create an unique one in the system folder.
  
  @param string $originalFilename
  @param array  $mediaFileInfo
  @return mixed