lib/oci/object_storage/transfer/upload_manager.rb
# Uploads an object to Object Storage. The object can be a path to a file, an IO-like object, or $stdin. Depending on
# the configuration of the UploadManager and the object provided, it may be uploaded in multiple parts. Note that input
# from $stdin will always be uploaded via a multipart upload.
#
# @param [String] namespace_name The namespace containing the bucket in which to store the object
# @param [String] bucket_name The bucket where we'll upload the object
# @param [String] object_name The name of the object in Object Storage
# @param [String, IO] object_io_or_file_path Either a path to the file to upload, an IO-like object containing the data to upload or $stdin.
#
# @param [Hash] opts the optional parameters
# @option opts [String] :if_match The entity tag to match
# @option opts [String] :if_none_match The entity tag to avoid matching. The only valid value is *, which indicates that the request should fail if the object already exists.
# @option opts [String] :opc_client_request_id The client request ID for tracing.
# @option opts [Integer] :content_length The content length of the body. This will be ignored for multipart uploads.
# @option opts [String] :content_type The content type of the object.  Defaults to 'application/octet-stream' if not overridden.
# @option opts [String] :content_language The content language of the object.
# @option opts [String] :content_encoding The content encoding of the object.
# @option opts [String] :content_md5 The base-64 encoded MD5 hash of the body. This will be ignored for multipart uploads.
# @option opts [Hash<String, String>] :metadata A hash of string keys to string values representing any custom metadata to be applied to the object.
# @option opts [String] :storage_tier :The storage tier that the object should be stored in. If not specified, the object will be stored in the same storage tier as the bucket.
#
# @return [Response] A Response object with data of type nil. For a multipart upload, the headers of the response will contain
# an opc-multipart-md5 key. For scenarios where the object was uploaded in a single part, the opc-content-md5 key will be
# present in the headers of the Response.
#
# @raise [OCI::Errors::MultipartUploadError] if an error occurred when performing a multipart upload. Consult the errors collection inside
# the exception to check the underlying errors which caused the failure.
Uploads an object to Object Storage. The object can be a path to a file, an IO-like object, or $stdin. Depending on
the configuration of the UploadManager and the object provided, it may be uploaded in multiple parts. Note that input
from $stdin will always be uploaded via a multipart upload.
Uploads an object to Object Storage . The object can be a path to a file an IO - like object or $stdin . Depending on the configuration of the UploadManager and the object provided it may be uploaded in multiple parts . Note that input from $stdin will always be uploaded via a multipart upload .
def upload(namespace_name, bucket_name, object_name, object_io_or_file_path, opts = {})
          raise 'A namespace_name must be provided' if namespace_name.nil?
          raise 'A bucket_name must be provided' if bucket_name.nil?
          raise 'An object_name must be provided' if object_name.nil?
          raise 'An object_io_or_file_path must be provided' if object_io_or_file_path.nil?
          content_length = File.size(object_io_or_file_path) if object_io_or_file_path.is_a?(String)
          unless object_io_or_file_path.is_a?(String)
            content_length = object_io_or_file_path.size if object_io_or_file_path.respond_to?(:size)
            content_length = object_io_or_file_path.stat.size unless object_io_or_file_path.respond_to?(:size)
          end
          return upload_multipart(namespace_name, bucket_name, object_name, object_io_or_file_path, opts) \
            if object_io_or_file_path.eql?($stdin)
          return upload_single(namespace_name, bucket_name, object_name, object_io_or_file_path, opts) \
            unless use_multipart?(content_length)
          upload_multipart(namespace_name, bucket_name, object_name, object_io_or_file_path, opts)
        end
def upload ( namespace_name , bucket_name , object_name , object_io_or_file_path , opts = { } ) raise 'A namespace_name must be provided' if namespace_name . nil? raise 'A bucket_name must be provided' if bucket_name . nil? raise 'An object_name must be provided' if object_name . nil? raise 'An object_io_or_file_path must be provided' if object_io_or_file_path . nil? content_length = File . size ( object_io_or_file_path ) if object_io_or_file_path . is_a? ( String ) unless object_io_or_file_path . is_a? ( String ) content_length = object_io_or_file_path . size if object_io_or_file_path . respond_to? ( :size ) content_length = object_io_or_file_path . stat . size unless object_io_or_file_path . respond_to? ( :size ) end return upload_multipart ( namespace_name , bucket_name , object_name , object_io_or_file_path , opts ) if object_io_or_file_path . eql? ( $stdin ) return upload_single ( namespace_name , bucket_name , object_name , object_io_or_file_path , opts ) unless use_multipart? ( content_length ) upload_multipart ( namespace_name , bucket_name , object_name , object_io_or_file_path , opts ) end
Uploads an object to Object Storage.
Uploads an object to Object Storage .
# $stdin is always multipart uploaded (since we can't always make a size guarantee). Otherwise, it depends on the UploadManager settings # and the size of the object identified by object_io_or_file_path
A Response object with data of type nil. For a multipart upload, the headers of the response will contain an opc-multipart-md5 key. For scenarios where the object was uploaded in a single part, the opc-content-md5 key will be present in the headers of the Response.
A Response object with data of type nil . For a multipart upload the headers of the response will contain an opc - multipart - md5 key . For scenarios where the object was uploaded in a single part the opc - content - md5 key will be present in the headers of the Response .
Response
[OCI::Errors::MultipartUploadError] if an error occurred when performing a multipart upload. Consult the errors collection inside the exception to check the underlying errors which caused the failure.
[ OCI :: Errors :: MultipartUploadError ] if an error occurred when performing a multipart upload . Consult the errors collection inside the exception to check the underlying errors which caused the failure .
namespace_name
bucket_name
object_name
object_io_or_file_path
opts
:storage_tier :The storage tier that the object should be stored in. If not specified, the object will be stored in the same storage tier as the bucket.
: storage_tier : The storage tier that the object should be stored in . If not specified the object will be stored in the same storage tier as the bucket .
opts the optional parameters
opts the optional parameters