Uploading Objects to a Bucket or Folder
Upload one or more objects to a bucket in Object Storage.
If the objects are larger than 64 MiB and multipart uploads is used, you need OBJECT_CREATE and OBJECT_OVERWRITE permissions.
To upload objects larger than 64 MiB, the Console uses multipart uploads. For details, seeUsing Multipart Uploads and Details for Object Storage, Archive Storage, and Data Transfer.
oci os object put --namespace <object_storage_namespace> --bucket-name <bucket_name> --file <file_location> [--name <object_name>] [--storage-tier <object_storage_tier>] --no-multipart
<file_location> is the source directory path of the object being uploaded, such as
C:\workspace\Uploads\MyFile.txt
or/home/user/Documents/Uploads/MyFile.txt
.<object_name> is the name of the uploaded object excluding the path. This parameter is required if the object is being read from STDIN. If you want to use the filename as the uploaded object's name (if not being read from STDIN), omit the
--name
option. The resulting object name does not include the path information (for example,C:\workspace\Uploads\
), just the actual file name by itself (MyFile.txt
).For example, to upload an object using the original filename, omit the
--name
option:oci os object put --namespace MyNamespace --bucket-name MyBucket --file C:\workspace\Uploads\MyFile.txt --no-multipart { "etag": "cadb9f8a-3292-45e6-a1e8-f075699fb619", "last-modified": "Fri, 11 Dec 2020 14:04:19 GMT", "opc-content-md5": "9P61OSaYe4fXxaeK8siuDw==" }
If you do not specify
--storage-tier
, the object is automatically assigned and uploaded to the default storage tier of the bucket (Standard or Archive).If you are uploading to a Standard tier bucket, you can specify--storage-tier <object_storage_tier>
to upload the object to a different storage tier:For example, to upload an object to the default storage tier of the bucket, omit
--storage-tier
:oci os object put --namespace MyNamespace --bucket-name MyStandardBucket --file C:\workspace\Uploads\MyFile.txt --name MyFile.txt --no-multipart { "etag": "cadb9f8a-3292-45e6-a1e8-f075699fb619", "last-modified": "Fri, 11 Dec 2020 14:04:19 GMT", "opc-content-md5": "9P61OSaYe4fXxaeK8siuDw==" }
Or:
oci os object put --namespace MyNamespace --bucket-name MyArchiveBucket --file C:\workspace\Uploads\MyFile.txt --name MyFile.txt --no-multipart { "etag": "cadb9f8a-3292-45e6-a1e8-f075699fb619", "last-modified": "Fri, 11 Dec 2020 14:04:19 GMT", "opc-content-md5": "9P61OSaYe4fXxaeK8siuDw==" }
For example, to upload an object to the Infrequent Access tier, specify--storage-tier
:oci os object put --namespace MyNamespace --bucket-name MyStandardBucket --file C:\workspace\Uploads\MyDocument.txt --storage-tier InfrequentAccess --no-multipart { "etag": "6b292c1a-b01b-4f36-97c8-4567fb43d071", "last-modified": "Sat, 12 Dec 2020 12:58:01 GMT", "opc-content-md5": "9P61OSaYe4fXxaeK8siuDw==" }
For example, to upload an object to the Archive tier, specify--storage-tier
:oci os object put --namespace MyNamespace --bucket-name MyStandardBucket --file C:\workspace\Uploads\MyDocument.txt --storage-tier Archive --no-multipart { "etag": "6b292c1a-b01b-4f36-97c8-4567fb43d071", "last-modified": "Sat, 12 Dec 2020 12:58:01 GMT", "opc-content-md5": "9P61OSaYe4fXxaeK8siuDw==" }
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 Using Multipart Uploads.To add optional response headers, use one or more of the following options:
-
--cache-control
-
--content-disposition
-
--content-encoding
-
--content-language
-
--content-disposition
-
--content-type
For more information about attributes that you can add when you upload an object, see Optional Response Headers and Metadata. For more details about these headers, see the Command Line Reference.
For example:
oci os object put --namespace MyNamespace --bucket-name MyBucket --file C:\workspace\MyFile --cache-control no-cache --no-multipart
To add custom metadata key-value pairs, use the
--metadata
option:oci os object put --namespace <object_storage_namespace> --bucket-name <bucket_name> --file <file_location> --name <object_name> --metadata <json_formatted_key-value_pairs> --no-multipart
<JSON-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 --namespace MyNamespace --bucket-name MyBucket --file C:\workspace\MyFile.txt --metadata '{"Department": "Finance"}' --no-multipart { "etag": "3504606b-8412-4b5d-924a-aeaeacf1df1e", "last-modified": "Wed, 20 Nov 2019 04:37:29 GMT", "opc-content-md5": "1B2M2Y8AsgTpgAmY7PhCfg==" }
Bulk Uploading Objects to a Bucket
oci os object bulk-upload --namespace <object_storage_namespace> --bucket-name <bucket_name> --src-dir <source_directory_location>
<source_directory_location> is the upload directory path, such as
C:\workspace\Upload\
or/home/user/Documents/Upload
. If your source directory has subdirectories, the subdirectory names are prepended to the names of the files stored in those subdirectories, delimited with a forward slash (/) character. For example, if a file namedmaple.jpg
is stored in the subdirectorytrees
, when the file is uploaded, Object Storage assigns the nametrees/maple.jpg
to the resulting object.If you are uploading to a Standard tier bucket, you can optionally specify the <object_storage_tier> to upload the object to:If you do not specify
--storage-tier
option, the object is uploaded to the default storage tier of the bucket.For example, to upload objects to the default storage tier of the bucket:
oci os object bulk-upload --namespace MyNamespace --bucket-name MyBucket --src-dir C:\workspace\Files Uploaded logFile.log [####################################] 100% Uploaded MyFile.txt [####################################] 100% { "skipped-objects": [], "upload-failures": {}, "uploaded-objects": { "MyFile.txt": { "etag": "e25f95e6-a2bd-435c-83d6-785f838134d5", "last-modified": "last-modified": "Sat, 12 Dec 2020 11:31:36 GMT", "opc-content-md5": "opc-content-md5": "vqglL/ToD0FxnqE83wBycw==" }, "logFile.log": { "etag": "bbcf33dd-a177-4406-bed1-a4f7125da800", "last-modified": "Sat, 12 Dec 2020 11:31:36 GMT", "opc-content-md5": "K8vB8NVASIvtL2BE5ksUjw==" } } }
For example, to upload objects to the Infrequent Access storage tier:
oci os object bulk-upload --namespace MyNamespace --bucket-name MyBucket --src-dir C:\workspace\Files --storage-tier InfrequentAccess Uploaded logFile.log [####################################] 100% Uploaded MyFile.txt [####################################] 100% { "skipped-objects": [], "upload-failures": {}, "uploaded-objects": { "MyFile.txt": { "etag": "e25f95e6-a2bd-435c-83d6-785f838134d5", "last-modified": "last-modified": "Sat, 12 Dec 2020 11:31:36 GMT", "opc-content-md5": "opc-content-md5": "vqglL/ToD0FxnqE83wBycw==" }, "logFile.log": { "etag": "bbcf33dd-a177-4406-bed1-a4f7125da800", "last-modified": "Sat, 12 Dec 2020 11:31:36 GMT", "opc-content-md5": "K8vB8NVASIvtL2BE5ksUjw==" } } }
For example, to upload objects to the Archive tier:
oci os object bulk-upload --namespace MyNamespace --bucket-name MyBucket --src-dir C:\workspace\Files --storage-tier Archive Uploaded logFile.log [####################################] 100% Uploaded MyFile.txt [####################################] 100% { "skipped-objects": [], "upload-failures": {}, "uploaded-objects": { "MyFile.txt": { "etag": "e25f95e6-a2bd-435c-83d6-785f838134d5", "last-modified": "last-modified": "Sat, 12 Dec 2020 11:31:36 GMT", "opc-content-md5": "opc-content-md5": "vqglL/ToD0FxnqE83wBycw==" }, "logFile.log": { "etag": "bbcf33dd-a177-4406-bed1-a4f7125da800", "last-modified": "Sat, 12 Dec 2020 11:31:36 GMT", "opc-content-md5": "K8vB8NVASIvtL2BE5ksUjw==" } } }
To append a prefix string to the object names created by your uploads, use the
--object-prefix
option. For example:oci os object bulk-upload --namespace MyNamespace --bucket-name MyBucket --src-dir C:\workspace\Files --object-prefix /bicycling/gloves/ Uploaded /bicycling/gloves/gloves_27_A.jpg [####################################] 100% Uploaded /bicycling/gloves/gloves_31_A.jpg [####################################] 100% { "skipped-objects": [], "upload-failures": {}, "uploaded-objects": { "/bicycling/gloves/gloves_27_A.jpg": { "etag": "7ba793ce-a341-4c56-9baf-61ca2c56ad50", "last-modified": "Sat, 12 Dec 2020 18:35:09 GMT", "opc-content-md5": "1B2M2Y8AsgTpgAmY7PhCfg==" }, "/bicycling/gloves/gloves_31_A.jpg": { "etag": "6efa58a6-a723-4696-a31f-3c5099adbec4", "last-modified": "Sat, 12 Dec 2020 18:35:09 GMT", "opc-content-md5": "6GxlLP9fa71HhVnpLNJ+DQ==" } } }
To add custom metadata key-value pairs, use the
--metadata <JSON_formatted_key-value_pairs>
option.<JSON-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 information about JSON formatting.
-
This task is not available in the API.