Updated on 2024-02-08 GMT+08:00

Accessing OBS

OBS Domain Name

The following two concepts are related to OBS domain names:

  1. Endpoint: OBS provides an endpoint for each region. An endpoint is a domain name to access OBS in a certain region and is used to receive access requests sent from that region. For the mapping between regions and OBS endpoints, see Regions and Endpoints.
  2. Bucket domain name: Each bucket in OBS has a domain name. A domain name is the Internet address of a bucket and can be used to access the bucket over the Internet. It is typically used in cloud application development and data sharing scenarios.

    An OBS bucket domain name is in the BucketName.Endpoint format.

    BucketName indicates the name of a bucket, and Endpoint indicates the OBS domain name of the region where the bucket is located.

Table 1 lists the bucket domain name, and other domain names of OBS, including their formats and protocols.

Table 1 OBS domain names

Type

Structure

Description

Protocol Type

Region domain name

[Structure]

Endpoint

[Example]

obs.ap-southeast-1.myhuaweicloud.com

Each region has an OBS endpoint, which is the OBS service domain name of the region.

For a complete mapping between regions and OBS endpoints, see Regions and Endpoints.

HTTPS

HTTP

Bucket domain name

[Structure]

BucketName.Endpoint

[Example]

bucketname.obs.ap-southeast-1.myhuaweicloud.com

After a bucket is created, you can use the domain name to access the bucket. You can assemble the domain name by putting the bucket name and endpoint together, or you can obtain it by viewing the basic bucket information on OBS Console or OBS Browser+.

HTTPS

HTTP

Object domain name

[Structure]

BucketName.Endpoint/ObjectName

[Example]

bucketname.obs.ap-southeast-1.myhuaweicloud.com/object.txt

After an object is uploaded to a bucket, you can use the object domain name to access the object. You can assemble the object domain name by putting the bucket name, OBS service endpoint, and object name together, or you can obtain it by Viewing Object Information on OBS Console or OBS Browser+. Alternatively, you can call the GetObjectUrl API through an SDK to obtain the object domain name.

HTTPS

HTTP

Static website domain name

[Structure]

BucketName.obs-website.Endpoint

[Example]

bucketname.obs-website.ap-southeast-1.myhuaweicloud.com

A static website domain name is a bucket domain name when the bucket is configured to host a static website.

HTTPS

HTTP

User-defined domain name

Domain names that have been licensed by the Ministry of Industry and Information Technology (MIIT) of China.

You can configure a user-defined domain name for a bucket so that you can access the bucket with the configured domain name.

HTTP

Endpoints

OBS has an endpoint in each region.

Generally, the endpoint carried in a request for accessing OBS must be the endpoint of the region where the requested resource resides. However, in some special cases, you can use any endpoint.

  1. Scenarios where the endpoint in a request must be the endpoint of the region where the requested resources reside

    When accessing a bucket or an object, the endpoint in the request must be the endpoint of the region where the bucket or object resides.

    For example, if bucket mybucket is in region ap-southeast-1, you can list objects in the bucket by sending a request shown in the following example:

    A correct example of request and response for listing objects:

    [Request]

    GET / HTTP/1.1  
    Host: mybucket.obs.ap-southeast-1.myhuaweicloud.com
    Accept: */*  
    Date: Thu, 10 Mar 2016 08:51:25 GMT  
    Authorization: authorization 

    [Response]

    HTTP/1.1 200 OK  
    x-obs-request-id: 0001EF710C000001536176DA465E4E6G  
    x-obs-id-2: Rdj0zZvRkihRcjcQUqjkDGt8JuAgi2CGuLiP7Pv/cYYplsS0xTFJQHP5vSg5yOYC  
    Content-Type: application/xml  
    Date: Thu, 10 Mar 2016 16:58:12 GMT  
    x-obs-bucket-location: ap-southeast-1
    Content-Length: 259  
    
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <ListBucketResult xmlns="http://obs.myhuaweicloud.com/doc/2015-06-30/">
      <Name>mybucket</Name>
      <Prefix/>
      <Marker/>
      <MaxKeys>1000</MaxKeys>
      <IsTruncated>false</IsTruncated>
      <Contents>
        <Key>object001</Key>
        <LastModified>2015-07-01T00:32:16.482Z</LastModified>
        <ETag>"2fa3bcaaec668adc5da177e67a122d7c"</ETag>
        <Size>12041</Size>
        <Owner>
          <ID>b4bf1b36d9ca43d984fbcb9491b6fce9</ID>
        </Owner>
        <StorageClass>STANDARD</StorageClass>
      </Contents>
    </ListBucketResult>

    If the endpoint in the request is not consistent with the endpoint of the requested region, an error message is returned indicating that the bucket does not exist.

    In the example above, bucket mybucket is in region ap-southeast-1. If you use the endpoint of cn-south-1 (mybucket.obs.cn-south-1.myhuaweicloud.com) to access the bucket, HTTP 404 is returned, indicating that the bucket does not exist. In this case, you can call the API for obtaining bucket location to obtain the bucket's region ID, and then send the request again.

    An incorrect example of request and response for listing objects:

    [Request]

    GET / HTTP/1.1  
    Host: mybucket.obs.cn-south-1.myhuaweicloud.com
    Accept: */*  
    Date: Thu, 10 Mar 2016 08:51:25 GMT  
    Authorization: authorization 

    [Response]

    HTTP/1.1 404 NoSuchBucket  
    x-obs-request-id: 0001EF710C000001536176DA465E4E6H  
    x-obs-id-2: Rdj0zZvRkihRcjcQUqjkDGt8JuAgi2CGuLiP7Pv/cYYplsS0xTFJQHP5vSg5yOYL  
    Date: Thu, 10 Mar 2016 08:51:30 GMT  
    Content-Length: 0  
  2. Scenarios where any endpoint can be used in a request

    You can use the endpoint of any region in the API requests for listing buckets and for obtaining a bucket's region information, because these two APIs search for buckets from all regions.

    An example of request and response for obtaining a bucket's region information:

    For example, if bucket mybucket is in region ap-southeast-1 and the endpoint of the cn-south-1 region is used in the request, the bucket location information can still be obtained.

    [Request]
    GET /?location HTTP/1.1  
    Host: mybucket.obs.cn-south-1.myhuaweicloud.com
    Accept: */*  
    Date: Thu, 10 Mar 2016 08:51:25 GMT  
    Authorization: authorization 
    [Response]
    HTTP/1.1 200 OK  
    x-obs-request-id: 0001EF710C000001536176DA465E4E6G  
    x-obs-id-2: Rdj0zZvRkihRcjcQUqjkDGt8JuAgi2CGuLiP7Pv/cYYplsS0xTFJQHP5vSg5yOYC  
    Content-Type: application/xml  
    Date: Thu, 10 Mar 2016 16:58:12 GMT  
    Content-Length: length  
    
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <Location xmlns="http://obs.myhuaweicloud.com/doc/2015-06-30/">ap-southeast-1</Location>

Accessing OBS over the Internet

Accessing OBS over a public network may generate inbound traffic for write operations (for example, uploading data to OBS), as well as outbound traffic for read operations (for example, downloading data from OBS). Inbound traffic does not incur fees, but outbound traffic does.

For details about the pricing of outbound traffic over the Internet, see Product Pricing Details.

If you access OBS over a public network, you can use a URL to specify resources in OBS. An OBS URL is structured as follows:

Protocol://[BukcetName.]Endpoint[:Port][/Object][?Param]

Table 2 Parameters in an OBS URL

Parameter

Description

Mandatory or Optional

Protocol

The protocol used for sending requests, which can be either HTTP or HTTPS. HTTPS is a protocol that ensures secure access to resources. OBS supports both HTTP and HTTPS.

Mandatory

BucketName

Name of the requested bucket, which uniquely identifies a bucket in OBS.

Optional

Endpoint

Domain name (endpoint) of the region where the OBS bucket is located.

For details about the OBS domain name of each region, see Regions and Endpoints.

Mandatory

Port

The port enabled for protocols used for sending requests. The value varies depending on software server deployment. If no port number is specified, the protocol uses the default value. Each transmission protocol has its default port number.

In OBS, the default HTTP port number is 80 and that of HTTPS is 443.

Optional

Object

Path of the requested object resource.

Optional

Param

Specific resource contained by a bucket or object. The default value of this parameter indicates that the bucket or object itself is obtained.

Optional

Example: You have a bucket named mybucket in the CN-Hong Kong (ap-southeast-1) region. The bucket contains an object named myfolder/myfile.txt. The URL for accessing the object over the public network is as follows:

https://mybucket.obs.ap-southeast-1.myhuaweicloud.com/myfolder/myfile.txt

All API requests except the one for listing objects must contain the BucketName. In consideration of the DNS resolution performance and reliability, OBS requires that the bucket name must precede the Endpoint when a request carrying a bucket name is constructed to form a three-level domain name, also mentioned as virtual hosting access domain name.

Accessing OBS over the Intranet

Accessing OBS over a private network refers to accessing OBS through the internal communication network between different Huawei Cloud services. Inbound traffic generated by accessing OBS over an intranet (write operations like uploading data to OBS) and outbound traffic (read operations like downloading data from OBS) are free of charge.

For example, you can access OBS from an Elastic Cloud Server (ECS) over a private network. Such access is not susceptible to public network quality issues, and it also reduces costs.

OBS provides you with a best practice for configuring such access. For details, see Accessing OBS from an ECS over the Intranet.

Checking OBS Version (OBS 2.0 or OBS 3.0)

OBS architecture has undergone two generations: OBS 2.0 and OBS 3.0. A newly created bucket is stored in OBS 3.0 by default, and the bucket version is OBS 3.0. However, previously created buckets are still in OBS 2.0.

Basic OBS features and functions are supported by both OBS 3.0 and OBS 2.0. Some new features are supported only by OBS 3.0, such as image processing and cross-region replication.

You can check the bucket version on OBS Console or use the Head Bucket API to check whether your bucket is in OBS 2.0 or OBS 3.0. The details are as follows:

Method 1: Log in to OBS Console and check the basic bucket information.

If Bucket Version is 3.0, the bucket is stored in OBS 3.0. If not, the bucket is stored in OBS 2.0.

Method 2: Use the Head Bucket API to check the bucket version.

Sample Request:

1
2
3
4
5
HEAD / HTTP/1.1
Host: bucketname.obs.ap-southeast-1.myhuaweicloud.com
Accept: */*
Date: WED, 01 Jul 2015 02:23:25 GMT
Authorization: auth string

Sample Response:

1
2
3
4
5
6
7
8
HTTP/1.1 200 OK
Server: OBS
x-obs-request-id: BF2600000163D80E4C5F20FDD5BD0085
Content-Type: application/xml
x-obs-version: 3.0
x-obs-id-2: 32AAAQAAEAABAAAQAAEAABAAAQAAEAABCS8wS9l00ll4oMWmdniV7XmdAvfewrQq
Date: WED, 01 Jul 2015 02:23:25 GMT
Content-Length: 0

In the response message, x-obs-version: 3.0 indicates that the bucket is stored in OBS 3.0. If this header does not exist or the value of this header is displayed otherwise, the bucket is stored in OBS 2.0.

For details about the Head Bucket API, see Obtaining Bucket Metadata.