Uploading an Object Storage Object to a Bucket
Upload an object to a bucket or folder in Object Storage.
To upload objects larger than 64 MiB, the Console uses multipart uploads. You need OBJECT_CREATE and OBJECT_OVERWRITE permissions to perform multipart uploads. For details, see Object Storage Multipart Uploads and Details for Object Storage, Archive Storage, and Data Transfer.
Use the prefix option to prepend a prefix value to any object's name that you upload to the bucket. You can use the prefix to search the bucket for only those objects whose names match the prefix. For example, if you included the prefix "test" during an object upload, all the included objects names are prepended with that prefix value. An object named "my-object.txt" is uploaded to the bucket as "testmy-object.txt."
See Object Naming Using Prefixes and Hierarchies for more information about creating prefixes for objects.
See Searching for Objects in a Bucket for more information on how to search for objects in a bucket using the prefix option.
Use the oci os object put command and required parameters to upload an object to a bucket:
oci os object put --bucket-name bucket_name --file file_location [OPTIONS]
where
file_location
is the source directory path of the object being uploaded, such asC:\workspace\Uploads\MyFile.txt
or/home/user/Documents/Uploads/MyFile.txt
. The uploaded object's name doesn't include the path information (for example,C:\workspace\Uploads\
), just the actual file name by itself (MyFile.txt
).An object can be uploaded as a single part or as multiple parts. Use the
--no-multipart
option to upload as a single part. For detailed information on multipart uploads, see Object Storage Multipart Uploads.For more information about attributes that you can add when you upload an object, see Optional Response Headers and Metadata.
To add custom metadata key-value pairs, use the
--metadata
option:oci os object put --bucket-name bucket_name --file file_location --name object_name --metadata json_formatted_key-value_pairs
whereJSON-formatted_key-value_pair
is a key-value pair input as valid formatted JSON. See Passing Complex Input and Using a JSON File for Complex Input for more information about JSON formatting.For example:
oci os object put --bucket-name MyBucket --file C:\workspace\MyFile.txt --metadata '{"Department": "Finance"}' { "etag": "3504606b-8412-4b5d-924a-aeaeacf1df1e", "last-modified": "Wed, 20 Nov 2019 04:37:29 GMT", "opc-content-md5": "1B2M2Y8AsgTpgAmY7PhCfg==" }
Specifying the Storage Tier of the Uploaded Object
Include the
storage-tier
parameter to assign a storage tier to the object you're uploading.oci os object put --bucket-name bucket_name --file file_location --storage-tier [Archive | InfrequentAccess | Standard] [OPTIONS]
For example, if you're uploading to a Standard tier-configured bucket and you want to assign the object to the InfrequentAccess storage tier, include
--storage-tier InfrequentAccess
in the command:
See Object Storage Storage Tiers for more information on how storage tiers work.oci os object put --bucket-name MyStandardBucket --file C:\workspace\Uploads\MyDocument.txt --storage-tier InfrequentAccess { "etag": "6b292c1a-b01b-4f36-97c8-4567fb43d071", "last-modified": "Sat, 12 Dec 2020 12:58:01 GMT", "opc-content-md5": "9P61OSaYe4fXxaeK8siuDw==" }
If you don't specify a storage tier in the command, the object is automatically assigned and uploaded to the default storage tier of the bucket (Standard or Archive).
Naming the Uploaded Object
Include the
name
parameter to name the uploaded object excluding its path. This parameter is required if the object is being read from STDIN. For example:oci os object put --bucket-name MyBucket --file C:\workspace\Uploads\MyFile.txt --name AboutMyCompany { "etag": "cadb9f8a-3292-45e6-a1e8-f075699fb619", "last-modified": "Fri, 11 Dec 2020 14:04:19 GMT", "opc-content-md5": "9P61OSaYe4fXxaeK8siuDw==" }
If you don't include the
name
parameter, the file name is used as the uploaded object's name (if not being read from STDIN)For a complete list of parameters and values for CLI commands, see the CLI Command Reference.
Run the PutObject operation to upload an object to a bucket.
Object Storage prepends the Object Storage namespace string and bucket name to the object name when constructing a URL for use with the API:
/n/object_storage_namespace/b/bucket/o/object_name
The object name is everything after the
/o/
, which could include hierarchy levels and prefix strings.