How to upload files by tasks?

This is a sample which uploads a remote file to the CMS storage (local or aws):

# lib/tasks/owen.rake
namespace :owen do
desc "Test download external image"
task download_image: :environment do
include Rails.application.routes.url_helpers
include CamaleonCms::SiteHelper
include CamaleonCms::HooksHelper
include CamaleonCms::UploaderHelper
def current_site; CamaleonCms::Site.first.decorate; end
result = upload_file('')
# sample result: {"name"=>"onn96a_top10groups2017_7.jpg", "key"=>"/onn96a_top10groups2017_7.jpg", "url"=>"http://localhost:3000/media/1/onn96a_top10groups2017_7.jpg", "is_folder"=>false, "size"=>35255.0, "format"=>"image", "deleteUrl"=>"", "thumb"=>"http://localhost:3000/media/1/thumb/onn96a_top10groups2017_7-jpg.jpg", "type"=>"image/jpeg", "created_at"=>2017-04-05 10:46:25 -0400, "dimension"=>"560x420"}

Note: to upload a local file, you can do it like:
result = upload_file('/myfolder/my_file.txt'))

To run the example:
rake owen:download_image

Created at: 05 Apr 14:46 | Updated at: 05 Apr 14:52