目录

Thumbnail:get

Function

Downloads the file's large thumbnail.

Scenario

By calling the Thumbnail.get API, your app can download the large thumbnail of a file (specified by fileId).

Restrictions

Prototype

Protocol

HTTP GET

Direction

Developer server -> HUAWEI Drive server

URL

https://driveapis.cloud.huawei.com.cn/drive/v1/thumbnails/{fileId}?form=content

Data Format

Request: Content-Type: application/json

Path Parameters

Parameter

Mandatory/Optional

Type

Description

fileId

Mandatory

string

File ID.

Query Parameters

Parameter

Mandatory/Optional

Type

Description

form

Mandatory

string

Media format.

quotaId

Optional

string

User identifier, which can contain a maximum of 40 characters. This parameter is used to restrict the maximum number of API calls for a single user.

Request Parameters

Request Header

Parameter

Mandatory/Optional

Type

Description

Authorization

Mandatory

string

User authorization information, that is, the access token (AT).

x-hw-trace-id

Optional

string

ID used for service tracing.

x-hw-app-id

Optional

string

App ID.

version

Optional

string

SDK version number.

x-hw-terminal

Optional

string

Device model.

x-hw-os

Optional

string

Device operating system.

unionID

Optional

string

User's UnionID.

User-Agent

Optional

string

App version number or app ID.

x-hw-deviceUUID

Optional

string

UUID of the device.

x-hw-deviceUDID

Optional

string

UDID of the device.

x-hw-appPackageName

Optional

string

App package name.

x-hw-network

Optional

string

Network type. The options include WiFi, 2G, 3G, 4G, 5G, and wire.

Cookie

Optional

string

Cookie, in which loginId is the session ID used for authentication.

Request Body

None.

Request Example

GET https://driveapis.cloud.huawei.com.cn/drive/v1/thumbnails/DSQpEkxcAAADKXEPJAYABgEZivNwAmCu?form=content HTTP/1.1 
Authorization: Bearer CV3PnPLZXyr9K2GV7RYZkF962JZvoEkMQhTho3QHQAPQUyma/lEyZskP/IMWrc7FvaeHivO7y0lyibI/fQvulBnTgtXArSVPsjaLKvYNkDsJSaIR2/sx+K40bYDWWpKFvJNKg2U47jRwz2mfiF3ortNk

Response Parameters

When the status code is 200:

Parameter

Type

Description

ThumbnailContent

string

Large thumbnail of the file.

Response Example

[imageData]

Common Result Codes

The last four digits in the result code indicate the service error code, which is used to differentiate error scenarios. For details about other service error codes, please refer to Status Codes.

Status Code

Result Code

Response Code

Description

200

NA

-

Success.

302

NA

-

You are redirected to another URL for download.

400

22004003

PARAM_VALUE_NOT_SUPPORT

The parameter is not supported. Check the parameter list.

400

22044002

PARAM_INVALID

Parameter verification failed. Check the parameter list.

400

22054002

PARAM_INVALID

Parameter verification failed. Check the parameter list.

400

22054003

PARAM_VALUE_NOT_SUPPORT

The parameter is not supported. Check the parameter list.

400

22054005

SITE_NOT_FOUND

Unknown site information.

400

22064002

PARAM_INVALID

Parameter verification failed. Check the parameter list.

400

22084002

PARAM_INVALID

Parameter verification failed. Check the parameter list.

400

22104001

LACK_OF_PARAM

Input parameter is missing. Check the parameter list.

400

22104002

PARAM_INVALID

Parameter verification failed. Check the parameter list.

400

22104003

PARAM_VALUE_NOT_SUPPORT

Invalid parameter. Check the parameter list.

400

22104004

PARAM_EXPIRED

The parameter is not supported. Check the parameter list.

400

22234002

PARAM_INVALID

Parameter verification failed. Check the parameter list.

401

22044011

USER_NOT_AUTHORIZED

User authentication failed. Check the parameter list.

401

22054011

USER_NOT_AUTHORIZED

User authentication failed.

403

22004032

SERVICE_NOT_SUPPORT

The service is not supported in the current country/region.

403

22004035

INSUFFICIENT_SCOPE

Scope verification failed.

403

22004037

OPERATION_NOT_COMPLETE

Operation failed due to an error.

403

22044033

AGREEMENT_NOT_SIGNED

The agreement is not signed. Try again after the agreement is signed.

403

22054034

CROSS_SITE_NOT_SUPPORT

Cross-site functions are restricted.

403

22064036

INSUFFICIENT_PERMISSION

No permission.

403

22104035

INSUFFICIENT_SCOPE

Scope verification failed.

403

22104038

OUTER_SERVICE_ERROR

An external service error occurred and cannot be rectified.

403

22124031

DATA_MIGRATINT

The security policy is being updated. Please wait until the update is complete.

403

22124032

SERVICE_NOT_SUPPORT

The service is not open.

403

22234035

INSUFFICIENT_SCOPE

Scope verification failed.

403

22234036

INSUFFICIENT_PERMISSION

No permission.

403

22234038

OUTER_SERVICE_ERROR

An external service error occurred and cannot be rectified.

404

22234041

CONTENT_NOT_FOUND

The content is not found.

429

22074291

USER_REQUEST_TOO_MANY

Too many user requests.

429

22074292

APP_REQUEST_TOO_MANY

Too many app requests.

500

22005006

SERVER_TEMP_ERROR

Temporary server error.

500

22065002

OUTER_SERVICE_UNAVAILABLE

External service is unavailable.

500

22065005

RESOURCE_LOCKED

Resource locked and cannot be operated currently.

500

22085006

SERVER_TEMP_ERROR

Temporary server error.

500

22105002

OUTER_SERVICE_UNAVAILABLE

External service is unavailable.

500

22105006

SERVER_TEMP_ERROR

Temporary server error.

500

22235002

OUTER_SERVICE_UNAVAILABLE

External service is unavailable.

Call Example

    public static void main(String[] args) throws IOException {
        // Set the request URL, file ID, and access token.
        String url = "https://driveapis.cloud.huawei.com.cn/drive/v1/thumbnails";
        String fileId = "AACUf44uK7wAg6pECq0Vh4QNqkgKoCuwA";
        String access_token = "CF3qHUcDOG3Rq+aCBdoTbdxTQYmIrt1c8xeVvh7Tquare/8VD+7YZFNxzuz5ZdhDrulEWOZVECrpQbVOqVMABeKe9p4wjL4UxskLw7KJKvs0fvZEJqjAKQ==";
        // Download a thumbnail.
        thumbnailGet(url, access_token, fileId);
    }

    private static void thumbnailGet(String url, String access_token, String fileId) throws IOException {
        StringBuilder stringBuilder = new StringBuilder("");
        stringBuilder.append("/").append(fileId);
        stringBuilder.append("?").append("form=content");
        HttpGet httpGet = new HttpGet(url + stringBuilder);
        httpGet.setHeader("Authorization","Bearer " + access_token);
        CloseableHttpResponse response = HttpClientUtil.getClient().execute(httpGet);

        try {
            HttpEntity responseEntity = response.getEntity();
            InputStream inputStream=responseEntity.getContent();
            FileUtils.copyToFile(inputStream, new File("D://thumbnail.jpg"));
        }finally {
            response.close();
        }
    }