What do you mean by programmatically? You can set up a method that will take a file path along the lines of
my_model_instance = MyModel.new
file = File.open(file_path)
my_model_instance.attachment = file
file.close
my_model_instance.save!
#attachment comes from our Paperclip declaration in our model. In this case, our model looks like
class MyModel < ActiveRecord::Base
has_attached_file :attachment
end
We’ve done things similar to this when bootstrapping a project.