Software

How to Delete an Object in OCI Object Storage Classic

OpenStack Swift API w/ Java

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;

public class OciClassicSample {

  public static void main(String[] args) {
    Client client = ClientBuilder.newClient();

    client.target("https://host/v1/sampleService-sampleIdentityDomain/sampleBucket/sampleObject").request().header("X-Auth-Token", ...).delete();

    client.close();
  }

}

OpenStack Swift API w/ Go

package main

import "gopkg.in/resty.v1"

func main() {
  resty.R().SetHeader("X-Auth-Token", ...).Delete("https://host/v1/sampleService-sampleIdentityDomain/sampleBucket/sampleObject")
}

OpenStack Swift API w/ Node.js

var https = require('https');

var req = https.request({ headers: { 'x-auth-token': ... }, hostname: 'host', method: 'DELETE', path: '/v1/sampleService-sampleIdentityDomain/sampleBucket/sampleObject' });

req.end();

OpenStack Swift API w/ Python

import requests

requests.delete('https://host/v1/sampleService-sampleIdentityDomain/sampleBucket/sampleObject', headers = { 'X-Auth-Token': ... })

OpenStack Swift API w/ Ruby

require 'rest-client'

RestClient.delete 'https://host/v1/sampleService-sampleIdentityDomain/sampleBucket/sampleObject', :x_auth_token => ...

OpenStack Swift CLI

1) Configure the CLI:

export ST_AUTH=https://host/auth/v1.0
export ST_USER=sampleservice-sampleidentitydomain:sampleuser
export ST_KEY=samplepassword

2) Run the following command:

swift delete samplebucket sampleobject

OpenStack Swift Client

from swiftclient.service import SwiftService

service = SwiftService({ 'auth': 'https://host/auth/v1.0', 'user': 'sampleService-sampleIdentityDomain:sampleUser', 'key': 'samplePassword' })

for res in service.delete('sampleBucket', [ 'sampleObject' ]):
  print res

OCI Classic FTM API

import oracle.cloudstorage.ftm.FileTransferAuth;
import oracle.cloudstorage.ftm.FileTransferManager;

public class OciClassicSample {

  public static void main(String[] args) {
    FileTransferManager ftm = FileTransferManager.getDefaultFileTransferManager(new FileTransferAuth("sampleUser", "samplePassword", "sampleService", "https://host/", "sampleIdentityDomain"));

    ftm.delete("sampleBucket", "sampleObject");

    ftm.shutdown();
  }

}

OCI Classic FTM CLI

1) Run the following command:

java -jar ftmcli.jar delete -U sampleuser -A https://host/ -S sampleservice -I sampleidentitydomain --save-auth-key samplebucket sampleobject

OCI Classic Java SDK

import oracle.cloud.storage.CloudStorage;
import oracle.cloud.storage.CloudStorageConfig;
import oracle.cloud.storage.CloudStorageFactory;

public class OciClassicSample {

  public static void main(String[] args) throws Exception {
    CloudStorage storage = CloudStorageFactory.getStorage(new CloudStorageConfig().setServiceName("sampleService-sampleIdentityDomain").setServiceUrl("https://host/").setUsername("sampleUser").setPassword("samplePassword"));

    storage.deleteObject("sampleBucket", "sampleObject");
  }

}

AWS CLI

1) Create the credentials file:

[default]
aws_access_key_id = sampleservice-sampleidentitydomain
aws_secret_access_key = samplesecretaccesskey

2) Run the following command:

aws s3api delete-object --bucket samplebucket --endpoint-url https://host/ --key sampleobject

Terraform OCI Classic Provider

1) Configure the provider:

export OPC_ENDPOINT=https://host/
export OPC_IDENTITY_DOMAIN=sampleidentitydomain
export OPC_USERNAME=sampleuser
export OPC_PASSWORD=samplepassword

2) If needed, import the object:

terraform import opc_storage_object.sampleobject sampleobject

3) Destroy the object.

Terraform OpenStack Provider

1) Configure the provider:

export OS_SWAUTH=true
export OS_AUTH_URL=https://host/
export OS_USERNAME=sampleservice-sampleidentitydomain:sampleuser
export OS_PASSWORD=samplepassword

2) If needed, import the object:

terraform import openstack_objectstorage_container_v1.sampleobject sampleobject

3) Destroy the object.

Terraform AWS Provider

1) Configure the provider:

provider "aws" {
  endpoints {
    s3 = "https://host/"
  }
  access_key = "sampleservice-sampleidentitydomain"
  secret_key = "samplesecretaccesskey"
  region = "us-east-1" # ignored
  skip_credentials_validation = true
  s3_force_path_style = true
}

2) If needed, import the bucket:

terraform import aws_s3_bucket_object.sampleobject sampleobject

3) Destroy the object.

s3cmd

1) Create the .s3cfg file:

[default]
host_base = host
host_bucket = host
access_key = sampleservice-sampleidentitydomain
secret_key = samplesecretaccesskey

2) Run the following command:

s3cmd del s3://samplebucket/sampleobject

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.