module OCI::Core::Util
This module contains utility methods for dealing with Core
Services (Compute, Block Volume and Networking)
Public Class Methods
file_content_as_launch_instance_user_data(file_path)
click to toggle source
Takes a file path and returns a Base64-encoded string which can be provided as the value of the `user_data` key in the `metadata` dictionary when launching an instance. See {OCI::Core::Models::LaunchInstanceDetails} for more information.
@param [String] file_path The path to the file to use for user_data
@return [String] A Base64-encoded string which can be used as the value of the `user_data` key in the
`metadata` dictionary when launching an instance
# File lib/oci/core/util.rb, line 18 def self.file_content_as_launch_instance_user_data(file_path) expanded_path = File.expand_path(file_path) raise 'The specified file does not exist' unless File.exist?(file_path) file_content = nil File.open(expanded_path, 'rb') do |file| file_content = file.read end Base64.strict_encode64(file_content) end