protected function createFromUrl($file)
    {
        $ch = curl_init();

        curl_setopt_array($ch, [
            CURLOPT_URL => $file,
            CURLOPT_RETURNTRANSFER => 1,
            CURLOPT_USERAGENT => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36',
            CURLOPT_FOLLOWLOCATION => 1,
        ]);

        $raw_file = curl_exec($ch);

        curl_close($ch);

        // Get the mime type of the file
        $size_info = getimagesizefromstring($raw_file);
        $mime = $size_info['mime'];

        // Create a file path for the file by storing it on disk.
        $file_path = @tempnam(sys_get_temp_dir(), 'STP');
        file_put_contents($file_path, $raw_file);

        // Get the original filename
        $name = strtok(pathinfo($file, PATHINFO_BASENAME), '?');

        // Append missing file extension
        if (empty(pathinfo($file, PATHINFO_EXTENSION))) {
            $name = $name . '.' . $this->getExtension($mime);
        }

        // Get the length of the file
        if (function_exists('mb_strlen')) {
            $size = mb_strlen($raw_file, '8bit');
        }
        else {
            $size = strlen($raw_file);
        }

        return new UploadedFile($file_path, $name, $mime, $size, 0);
    }