You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: uploader.rb
    path of file: ./repos/discourse/script/import_scripts/base
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

module ImportScripts
  class Uploader
    # Creates an upload.
    # Expects path to be the full path and filename of the source file.
    # @return [Upload]
    def create_upload(user_id, path, source_filename)
      tmp = copy_to_tempfile(path)

      UploadCreator.new(tmp, source_filename).create_for(user_id)
    rescue => e
      STDERR.puts "Failed to create upload: #{e}"
      nil
 
    
    def create_avatar(user, avatar_path)
      tempfile = copy_to_tempfile(avatar_path)
      filename = "avatar#{File.extname(avatar_path)}"
      upload = UploadCreator.new(tempfile, filename, type: "avatar").create_for(user.id)

      if upload.present? && upload.persisted?
        user.create_user_avatar
        user.user_avatar.update(custom_upload_id: upload.id)
        user.update(uploaded_avatar_id: upload.id)
      else
        STDERR.puts "Failed to upload avatar for user #{user.username}: #{avatar_path}"
        STDERR.puts upload.errors.inspect if upload
      end