API Developers

Object Storage (HAN02) provides a range of APIs for managing data and interacting with your cloud storage resources. Here is a summary of the main types of APIs we provide:

  • vStorage API: you can use Service Account to authenticate and work with projects, buckets, objects, reports via API.

  • S3 API : you can use S3 keys to authenticate and work with buckets and objects via API.

vStorage API - Authentication

Follow the steps below to work with vStorage via Service Account

  1. Select the Integration folder .

  2. Select the vStorage API icon .

  3. In the Authentication section , you need to fill in the necessary information to configure your vStorage API including:

    1. Enter the Client ID . A Client ID is a string of characters used by the Service API to identify your application, and is also used to construct the "authorization URL" displayed to the user. You can create and manage Client IDs through the vIAM system. The Client ID is automatically generated when you create a new Service Account .

    2. Enter the Client Secret corresponding to the Client ID you just entered. The Client ID and Client Secret pair are created and managed by you through the vIAM system. You can select Click here to manage your Client ID. so we can navigate you to the vIAM system and in detail the Service Account management screens.

  4. Once you've finished selecting your authentication configuration , select Authentication to go to the Configuration screen . Here you can use the vStorage APIs directly, or you can use the API via Postman . You can always come back here to change your Authorization information , then select Authentication again to update the S3 Rest API list with your new parameters.

For details, please refer to https://docs.api.vngcloud.vn/service-docs/vstorage-han02-api.html .

S3 API - Authentication

  • Type: AWS Signature

  • Access Key: initialize and retrieve information on the vStorage Portal.

  • Secret Key: initialize and retrieve information on vStorage Portal.

  • Region: HAN02

For example:


Working with Bucket

These APIs allow you to manage buckets.

1. Basic APIs

  • Create Bucket : Create a new bucket.

    • Path: PUT /<bucket-name>

    • For example: PUT https://han02.vstorage.vngcloud.vn/demobucket

    • Or Curl via command:

  • List Buckets : List all buckets belonging to the user.

    • Path: GET /

    • For example: GET https://han02.vstorage.vngcloud.vn/

    • Or Curl via command:

  • Delete Bucket : Delete a bucket (only if the bucket is empty).

    • Path: DELETE /<bucket-name>

    • For example: DELETE https://han02.vstorage.vngcloud.vn/demobucket

    • Or Curl via command:

  • GET Bucket (List Objects) : List objects in a bucket.

    • Path: GET /<bucket-name>

    • For example: GET https://han02.vstorage.vngcloud.vn/demobucket

    • Or Curl via command:

  • HEAD Bucket : Check for existence and access to bucket.

    • Path: HEAD /<bucket-name>

    • For example: HEAD https://han02.vstorage.vngcloud.vn/demobucket

    • Or Curl via command:

2. Access Control APIs

Manage access rights for buckets and objects.

  • GET Bucket ACL : Get the bucket's access control list (ACL).

    • Path: GET /<bucket-name>?acl

    • For example: GET https://han02.vstorage.vngcloud.vn/demobucket?acl

    • Or Curl via command:

  • PUT Bucket ACL : Set ACL for bucket.

    • Path: PUT /<bucket-name>?acl

    • For example: PUT https://han02.vstorage.vngcloud.vn/demobucket?acl

    • Or Curl via command:

  • GET Object ACL : Get the ACL of an object.

    • Path: GET /<bucket-name>/<object-key>?acl

    • For example: GET https://han02.vstorage.vngcloud.vn/demobucket/videoplayback.mp4?acl

    • Or Curl via command:

  • PUT Bucket Make Public: Set up a Public Bucket

    • Path: GET /<bucket-name>/?publicAccessBlock

    • For example: PUT https://han02.vstorage.vngcloud.vn/demobucket01/?publicAccessBlock

    • Or Curl via command:

  • GET Bucket Make Public: Get public or private bucket information.

    • Path: GET /<bucket-name>/?publicAccessBlock

    • For example: GET https://han02.vstorage.vngcloud.vn/demobucket01/?publicAccessBlock

    • Or Curl via command:

3. Versioning API

Manage versions of objects in buckets.

  • PUT Bucket Versioning : Enable or disable versioning for the bucket.

    • Path: PUT /<bucket-name>?versioning

    • For example: PUThttps://han02.vstorage.vngcloud.vn/demobucket?versioning

    • Or Curl via command:

  • GET Bucket Versioning : Check the bucket versioning status.

    • Path: GET /<bucket-name>?versioning

    • For example: GET https://han02.vstorage.vngcloud.vn/demobucket?versioning

    • Or Curl via command:

  • GET Object Versions : List versions of objects in the bucket.

    • Path: GET /<bucket-name>?versions

    • For example: GET https://han02.vstorage.vngcloud.vn/demobucket/?versions

    • Or Curl via command:

4. API Lifecycle

Lifecycle management for buckets and objects:

  • PUT Bucket Lifecycle : Initializes lifecycle expiration for a bucket.

    • Path: PUT /<bucket-name>?lifecycle

    • For example: PUT https://han02.vstorage.vngcloud.vn/demobucket?lifecycle

    • Or Curl via command:

  • GET Bucket Lifecycle : Get bucket lifecycle rule information.

    • Path: GET /<bucket-name>?lifecycle

    • For example: GET https://han02.vstorage.vngcloud.vn/demobucket?lifecycle

    • Or Curl via command:

  • DELETE Bucket Lifecycle : Deletes the lifecycle rules set for the bucket.

    • Path: DELETE /<bucket-name>?lifecycle

    • For example: DELETE https://han02.vstorage.vngcloud.vn/demobucket?lifecycle

    • Or Curl via command:

5. CORS API

Manage access and use S3 as a static website hosting service.

  • PUT Bucket Website : Set up the bucket as a static website.

    • Path: PUT /<bucket-name>?cors

    • For example: PUT https://han02.vstorage.vngcloud.vn/demobucket?cors

    • Or Curl via command:

  • GET Bucket Website : Get the bucket's website configuration.

    • Path: GET /<bucket-name>?cors

    • For example: GET https://han02.vstorage.vngcloud.vn/demobucket?cors

    • Or Curl via command:

  • DELETE Bucket Website : Deletes the bucket's website configuration.

    • Path: DELETE /<bucket-name>?website

    • For example: DELETE https://han02.vstorage.vngcloud.vn/demobucket?cors

    • Or Curl via command:


6. API Object Locked

Attention:

  • To set Object Locked for a bucket, when initializing the bucket, you need to add the parameter x-amz-bucket-object-lock-enabled = true

Set Object Locked via API.

  • Update Object Locked Configuration: Used to upload objects into a bucket.

    • Path: PUT /<bucket-name>?object-lock

    • For example: PUT https://han02.vstorage.vngcloud.vn/demoobjectlocked?object-lock

    • Or Curl via command:


Working with Objects

These are the basic APIs for manipulating objects (files) in S3.

  • PUT Object : Used to upload objects into a bucket.

    • Path: PUT /<bucket-name>/<object-key>

    • For example: PUT https://han02.vstorage.vngcloud.vn/demobucket/demoobject.txt

    • Or Curl via command:

  • GET Object : Get an object from S3.

    • Path: GET /<bucket-name>/<object-key>

    • For example: GET https://han02.vstorage.vngcloud.vn/demobucket/demoobject.txt

    • Or Curl via command:

  • DELETE Object : Delete an object from S3.

    • Path: DELETE /<bucket-name>/<object-key>

    • For example: DELETE https://han02.vstorage.vngcloud.vn/demobucket/demoobject.txt

    • Or Curl via command:

Attention:

  • To delete a version object, you need to add the versionId param to this API. For example, to delete the test.txt object with version-id = "z3-o0S5HEC6-XsjEjuHoRwoE-F6X1IF", you can curl the following command:

  • HEAD Object : Query object metadata without downloading content.

    • Path: HEAD /<bucket-name>/<object-key>

    • For example: HEAD https://han02.vstorage.vngcloud.vn/demobucket/demoobject.txt

    • Or Curl via command:

  • COPY Object : Copy an object from one S3 location to another.

    • Request: PUT /<destination-bucket>/<destination-object-key> với header x-amz-copy-source.

    • For example: PUT https://han02.vstorage.vngcloud.vn/demobucket01/demoobject.txt

    • Or Curl via command:

Last updated