Accessing Object Storage using Swift Endpoints with Curl

Gain access to Object Storage and run tasks using Swift API endpoints with Curl.

Run the following Object Storage tasks using Swift API with Curl using the following command syntax. Include the appropriate username, token, namespace, and bucket. For a list of supported Swift API endpoints, see Swift API Endpoints.

You must specify a compartment for the S3 Compatibility API. By default, buckets created using the Amazon S3 Compatibility API or the Swift API are created in the root compartment of the Oracle Cloud Infrastructure tenancy. You can select a different compartment where the Amazon S3 Compatibility API or Swift API can create buckets. For more information, see Object Storage Compartments for the Amazon S3 Compatibility API and Swift API.

For more information on using Curl, see curl man page.

Listing Objects in a Bucket

Enter the following command at the prompt:
curl -u 'username:token' -v <swift_api_endpoint>/v1/<namespace>/<bucket_name>

For example:

curl -u 'myuser:mytoken' -v https://swiftobjectstorage.us-ashburn-1.oraclecloud.com/v1/mynamespace/mybucket

For more information, see Listing Objects in a Bucket.

Uploading an Object to a Bucket

Enter the following command at the prompt:

curl -u 'username:token' -v -X PUT <swift_api_endpoint>/v1/<namespace>/<bucket_name>/<object_name> -T <uploaded_object_name>

For example:

curl -u 'myuser:mytoken' -v -X PUT https://swiftobjectstorage.us-phoenix-1.oraclecloud.com/v1/mynamespace/mybucket/myfile.txt -T myuploadedfile.txt

For more information, see Uploading an Object to a Bucket.

Downloading an Object from a Bucket

Enter the following command at the prompt:

curl -u 'username:token' -v -X GET <swift_api_endpoint>/v1/<namespace>/<bucket_name>/<object_name> -o <downloaded_object_name>

For example:

curl -u 'myuser:mytoken' -v -X GET https://swiftobjectstorage.ca-toronto-1.oraclecloud.com/v1/mynamespace/mybucket/myfile.txt -o mydownloadedfile.txt

For more information, see Downloading an Object from a Bucket.

Swift API Endpoints

Use the appropriate Swift API endpoint according to the Oracle Cloud Infrastructure region where your tenancy resides:

  • https://swiftobjectstorage.us-ashburn-1.oraclecloud.com
  • https://swiftobjectstorage.us-phoenix-1.oraclecloud.com
  • https://swiftobjectstorage.ca-toronto-1.oraclecloud.com
  • https://swiftobjectstorage.uk-london-1.oraclecloud.com
  • https://swiftobjectstorage.eu-frankfurt-1.oraclecloud.com