Updated on 2025-08-14 GMT+08:00

Uploading a File

Function

Upload local files to the storage. By default, files are uploaded to the first bucket set up for the connector. These files can be texts, images, or videos.

URI

POSTHuawei Cloud Astro Zero domain name/u-route/baas/sys/v1.1/connectors/{connector_type}/{connector_name}/putobject?object=X

Table 1 URI parameters

Parameter

Mandatory

Type

Description

connector_type

Yes

String

Explanation

Type of a connector.

Constraints

None

Value

  • obs: connector for interconnecting with OBS.
  • minio: connector for connecting to MINIO.
  • objectstorageproxy: object storage proxy type.

Default value

None

connector_name

Yes

String

Explanation

Name of the connector instance, that is, the connector instance name set when the connector is created.

Constraints

None

Value

None

Default value

None

object

No

String

Explanation

Full path of the file to be uploaded in the bucket, including the file name, file type, and upload path. If no path is specified, the file is uploaded to the root directory of the bucket.

For example, if the value is a/b/c/1.txt, file 1.txt is uploaded to the a/b/c path of the bucket. If the path does not exist in the bucket, it will be created.

Constraints

None

Value

None

Default value

None

Request Parameters

Body type in the request, in the multipart/form-data format.

Table 2 Request parameters

Parameter

Mandatory

Type

Description

dir

No

String

Explanation

Directory of the file to be uploaded in the bucket.

Constraints

None

Value

None

Default value

If this parameter is left blank, the root directory of the bucket is used.

acl

No

String

Explanation

Access control permission on uploaded files.

Constraints

None

Value

  • private
  • public-read
  • public-read-write
  • default: The permission is the same as that configured for the bucket.

Default value

If this parameter is not configured, the permission configured for the bucket is used.

object

Yes

String

Explanation

File data to be uploaded, including the file name and content.

Constraints

None

Value

None

Default value

None

Response Parameters

Table 3 Response parameters

Parameter

Type

Description

resCode

String

Explanation

Return code.

Value

If the request is successful, 0 is returned. For details about other error codes, see Error Codes.

resMsg

String

Explanation

Message returned.

Value

If the request is successful, "Success" is returned. In other cases, an error message is returned.

result

Object

Explanation

If the request is successful, the path of the uploaded file in the bucket is returned.

Example Request

Create an OBS connector. Assume that the connector instance name is namespace__TestOBS. Upload the 1.txt file to the a/b/c directory of the OBS bucket. When you call an API to upload a file, the file can be uploaded only to the first bucket configured for the connector.

POST https://Huawei Cloud Astro Zero domain name/u-route/baas/sys/v1.1/connectors/obs/Namespace __TestOBS/putobject?object=a/b/c/1.txt

{
    "object": "File to be uploaded",
    "acl": "public-read-write",
    "dir": "/"
}

In the request parameters, set the object in the multipart/form-data format, that is, the file data to be uploaded.

Figure 1 Setting the request parameter

After the preceding operations are complete, the 1.txt file is successfully uploaded to the a/b/c directory in the OBS bucket.

Example Response

{
 "resCode": "0",
	"resMsg": "Success",
 "result": {
  "object": "a/b/c/1.txt"
 }
}

Status Code

See Status Codes.

Error Code

See Error Codes.