getImageTransferConfig(data: GetImageTransferConfigParams)

Requires:
@tuya-miniapp/cloud-api≥1.6.0

Description

Get the image transfer upload bucket config and temporary credentials

Parameters

ParameterTypeRequiredDescription
YesRequest parameters

Return Value

Type: Promise<GetImageTransferConfigResult>
GetImageTransferConfigResult: session ID, skill, upload prefix, upload credentials, etc.

Referenced Types

interfaceGetImageTransferConfigResultResult of getting the device image transmission configuration
PropertyTypeDescription
sidstringSession ID provided by the caller or generated by the server
Parsed skill JSON
prefixstringUpload path prefix (must be passed back unchanged as path when calling save)
credentialsImageTransferCredentialsUpload credentials
metastringCaller uid
levelnumberEncryption level, fixed at 3

Examples

Request example

import { getImageTransferConfig } from '@tuya-miniapp/cloud-api';

getImageTransferConfig({
  devId: '6cbed8370dd694e247uk9u',
  fileType: 'jpg',
})
  .then(response => {
    console.log(response);
  })
  .catch(error => {
    console.error('Failed to get image transfer config:', error);
  });

Response example

{
  "sid": "session_123456789",
  "skill": {},
  "prefix": "tc_permanent/123456789",
  "credentials": {
    "bucket": "tuya-tc-permanent",
    "path": "tc_permanent/123456789"
  },
  "meta": "your_user_id",
  "level": 3
}

FAQ

Why does the call to cloud capabilities fail?

Before using this API, please ensure that the product to which the device belongs has enabled the Image Transfer advanced capability on the Tuya IoT Development Platform. Devices without this capability enabled cannot perform image upload or printing, and the API will return empty data or an error. If you need to use it, please create a product that supports image transfer/printing functions and enable the corresponding advanced capabilities in the product details. At the same time, the API depends on cloud capabilities, and authorization configuration is required in Development Settings - Cloud Capabilities on the Mini Program Developer Platform.