fetchDeviceFileSign(bizType: string, fileName: string, contentType: string)

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

Description

Get temporary storage upload signature

Parameters

ParameterTypeRequiredDescription
bizTypestringYesBusiness type
fileNamestringYesFile name to be stored
contentTypestringYesFile category

Return Value

Type: Promise<FileSign>
FileSign: action (temporary storage signature), token (key for querying the storage result)

Referenced Types

typeFileSignTemporary upload signature returned by `fetchDeviceFileSign`.
PropertyTypeDescription
actionstringTemporary storage signature (used with the upload SDK)
tokenstringKey for querying the storage result, used for `fetchDeviceFileUploadState`

Examples

Request example

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

fetchDeviceFileSign('pet_media', 'clip.wav', 'audio/wav')
  .then((sign) => {
    console.log(sign);
  })
  .catch();

Response example

{
  "action": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "token": "upload-token-abc123"
}