Updated on 2024-12-02 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

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

Parameters

Parameter

Mandatory/Optional

Type

Description

object_device_id

Optional

String

Explanation:

  • For gateway device: The value is the child device ID in the topic.
  • For directly connected device: The value is the same that of device_id in the topic.

services

Optional

List<ServiceEvent>

Explanation:

List of services that an event is about.

ServiceEvent structure

Parameter

Mandatory/Optional

Type

Description

service_id

Mandatory

String

Explanation:

System field.

Value range:

Fixed at $file_manager.

event_type

Mandatory

String

Explanation:

System field.

Value range:

Fixed at get_upload_url_response.

event_time

Optional

String

Explanation:

Event time. UTC time format: yyyyMMdd'T'HHmmss'Z'.

paras

Mandatory

Object

Explanation:

Event parameters in JSON format.

paras structure

Parameter

Mandatory/Optional

Type

Description

url

Mandatory

String

Explanation:

File upload URL.

bucket_name

Optional

String

Explanation:

OBS bucket name.

object_name

Optional

String

Explanation:

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

expire

Optional

Integer

Explanation:

URL expiration time, in seconds.

file_attributes

Optional

Object

Explanation:

File attributes, which are objects 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
            }
         } 
    }] 
}