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.

    1. Open the navigation menu and click Storage. Under Object Storage & Archive Storage, click Buckets.
    2. Select the compartment from the list under List Scope. All buckets in that compartment are listed in tabular form.
    3. Click the bucket where you're uploading objects. The bucket's Details page appears.
    4. Click Objects under Resources. The Objects list appears. All folders and objects are listed in tabular form.
    5. Click Upload. To upload objects to a folder or subfolder in the Objects list, open that folder and click Upload. The Upload Objects dialog box appears.
    6. Complete the following:
      • Object Name Prefix: (optional) If provided, this prefix is prepended to each one of the files you upload.

        • Prefix strings with a forward slash ("/") delimiter to simulate hierarchy and create folders or subfolders.

        • Prefix strings without a delimiter for matching purposes to perform allowed bulk operations.

        For details, see Object Naming Using Prefixes and Hierarchies.

      • Storage Tier: Specify the type of storage tier the object being uploaded belongs to:

        • Standard Tier

        • Infrequent Access

        • Archive

        See Object Storage Storage Tiers for descriptions of the storage tier types.

        Note

        Standard storage tier buckets can contain a mix of objects with different storage tier assignments. An object remains in the Standard bucket, even if the object is archived, restored, or if tier assignment is changed.

    7. Select the objects that you want to upload into the Choose Files from your Computer box using one of the following methods:
      • Drag one or more files from your computer into the box.

      • Click the select files link to display a file selection dialog box where you can navigate to the files you want to upload.

      The files you select to upload are displayed in a list. To remove a selected file from being uploaded, click the X next to the file name.

      If the files you select to upload are already stored in the bucket or folder with the same name, the Console displays messages warning you of an overwrite.

    8. (Optional) Click Show Optional Response Headers and Metadata to specify values for optional response headers and metadata to be displayed in the Object Details dialog box.
      1. Select the type of attribute that you're adding:

        • To add a response header, select a value in the Name list and then enter a value in the Value box.

        • To add metadata, enter a value in the Name box and then enter a value in the Value box.

      2. To add another attribute, click + Add More Headers or Metadata. To delete an attribute, click the X next to the attribute.

    9. Click Upload. The selected objects are uploaded and displayed in the list of objects in the bucket or folder.
  • 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 as C:\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
    where 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 --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:

    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=="
    }
    See Object Storage Storage Tiers for more information on how storage tiers work.

    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.