Updated on 2023-02-16 GMT+08:00

Platform Delivering a Temporary URL for File Upload

Function

This API is used by the platform to deliver a temporary URL for file upload.

Topic

$oc/devices/{device_id}/sys/events/down

Parameters

Parameter

Mandatory or Optional

Type

Description

object_device_id

Optional

String

Indicates the device that the event is about. If this parameter is not carried, the device specified in the topic is considered to be the device involved.

services

Optional

List<ServiceEvent>

Indicates a list of services that the event is about.

ServiceEvent structure

Parameter

Mandatory or Optional

Type

Description

service_id

Mandatory

String

System field. The value is fixed to $file_manager.

event_type

Mandatory

String

System field. The value is fixed to get_upload_url_response.

event_time

Optional

String

Indicates the time when the event occurs.

paras

Mandatory

Object

Indicates the event parameters in JSON format.

paras structure

Parameter

Mandatory or Optional

Type

Description

url

Mandatory

String

Indicates the URL for file upload.

bucket_name

Optional

String

Indicates the name of an OBS bucket.

object_name

Optional

String

Indicates the name of the object to be uploaded to OBS, which is the same as the value of file_name.

expire

Optional

Integer

Indicates the URL validity period, in seconds.

file_attributes

Optional

Object

Indicates the file attributes in JSON format.

Example

Topic: $oc/devices/{device_id}/sys/events/down  
Data format:
{ 
    "object_device_id": "{object_device_id}", 
    "services": [{ 
        "service_id": "$file_manager", 
        "event_type": "get_upload_url_response", 
        "event_time": "20151212T121212Z",
         "paras": { 
            "url":"https://bucket.obs.cn-north-4.com/device_file/aGEKIpp5NAGxdP2oo90000/a.jpg?Expires=1553162075&OSSAccessKeyId=LTAIYLScbHiV****&Signature=%2F88xdEFPukJ****%2F8****%2Bdv3io%3D",
            "bucket_name":"bucket",
            "object_name": "c6b39067b0325db34663d3ef421a42f6_12345678_a.jpg",
            "expire":3600,
            "file_attributes": {
                "hash_code": "58059181f378062f9b446e884362a526",
                "size": 1024
            }
         } 
    }] 
}