Using API

E2E Object Storage supports a range of REST endpoints for seamless integration with external applications and plugins.

Getting Started

Object Storage is capable of supporting any API SDK thats s3 compliant but we recommend using Minio SDKs for best experience.

In this article, we will use python to demonstrate API examples but you may use other languages as per your comfort.

Pre-requisites

  • Your will need Python 2.7 or higher

  • You will need to a storage bucket and credentials (access/secret key).

  • Install minio python sdk:

pip install minio

Initialize Client

Endpoint URLs

  • Delhi-NCR : objectstore.e2enetworks.net

  • Mumbai : mum-objectstore.e2enetworks.net

from minio import Minio

eos_client = Minio('<<endpoint_url>>',
                   access_key='<<enter access key here>>',
                   secret_key='<<enter secret key here>>',
                   secure=True)

List objects from a bucket

# method: list_objects
# params: bucket_name, prefix (object path prefix), recursive (set True for directories)

objects = eos_client.list_objects('<<bucketname>>',
                                  prefix='<<enter path here. e.g. / for root>>',
                                  recursive=False)


for obj in objects:
    print(obj.bucket_name, obj.object_name, obj.last_modified, obj.size, obj.content_type)

Get object

# method: get_object
# params: bucket_name, object name (object full path)
from minio.error import ResponseError

try:
    data = eos_client.get_object('bucketname', 'objectname')
    with open('test-file', 'wb') as file_data:
        for d in data.stream(32*1024):
            file_data.write(d)
except ResponseError as err:
    print(err)

Put object

# method: get_object
# params: bucket_name, object name (object full path),
#         file pointer, size of file, content type

from minio.error import ResponseError

try:
    with open('/local_dir/test-file.csv', 'rb') as file_data:

        file_stat = os.stat('/local_dir/test-file.csv')
        eos_client.put_object('bucketname', 'objectname',
                              file_data, file_stat.st_size,
                              content_type='application/csv')

except ResponseError as err:
    print(err)

Remove Object

# method: remove_object
# params: bucket_name, object name (object full path)
from minio.error import ResponseError

try:
    eos_client.remove_object('bucketname', 'objectname')
except ResponseError as err:
    print(err)

Remove Objects

# method: remove_objects
# params: bucket_name, object prefix (e.g. directory path)
from minio.error import ResponseError

try:
    get_name = lambda object: object.object_name
    names = map(get_name, client.list_objects_v2('bucketname', 'path', recursive=True))

    for err in client.remove_objects('bucketname', names):
        print("Deletion Error: {}".format(err))
except ResponseError as err:
    print(err)

Supported Operations

At the moment, the following object level operations are supported. But we intend to add more bucket and admin level functions soon. Please feel free to write to us for feature requests.

list_objects

get_object

remove_object

put_object

copy_object

remove_objects

fput_object

fget_object

get_partial_object

select_object_content

remove_incomplete_upload

presigned_get_object

presigned_put_object

list_objects

get_object

put_object

copy_object

remove_object

remove_objects

fput_object

fget_object

get_partial_object

select_object_content

remove_incomplete_upload

presigned_get_object

presigned_put_object