def file_upload filename, upload_options={}
if File.exists? filename
StudioApi::File.find(:all, :params => {
:appliance_id => self.options.appliance_id
}).select { |file|
file.path == (upload_options[:path] || '/') and file.filename == File.basename(filename)
}.each(&:destroy)
message = "Uploading #{filename} "
message += "(#{Utils.readable_file_size(File.size(filename),2)})"
Utils::execute_printing_progress message do
File.open(filename) do |file|
StudioApi::File.upload file, @options.appliance_id, upload_options
end
end
true
else
STDERR.puts "Cannot upload #{filename}, it doesn't exists."
false
end
end