Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
Software Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
Help Center/ MetaStudio/ API Reference/ Asset Management/ File Management/ Creating a File and Obtaining the URL for File Upload

Creating a File and Obtaining the URL for File Upload

Function

You can create a file and obtain the URL for file upload.

Calling Method

For details, see Calling APIs.

URI

POST /v1/{project_id}/files

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details about how to obtain the project ID, see Obtaining a Project ID.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

No

String

User token. This parameter is mandatory when token authentication is used.

You can obtain the token by calling the IAM API used to obtain a user token.

Value of X-Subject-Token in the response header.

Authorization

No

String

Authentication information. This parameter is mandatory for AK/SK authentication.

X-Sdk-Date

No

String

Time when the request is sent. This parameter is mandatory for AK/SK authentication.

The format is YYYYMMDD'T'HHMMSS'Z'.

X-App-UserId

No

String

Third-party user ID, which does not allow Chinese characters.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

file_name

Yes

String

Details:

File name.

Constraints:

It is case-insensitive.

Options:

The value contains 1 to 256 characters.

Default value:

N/A

file_md5

Yes

String

Details:

MD5 value of the file content. Base64-encoded 128-bit MD5 digest of the message according to RFC 1864.

Constraints:

N/A

Options:

The value contains 24 characters.

Default value:

N/A

file_size

Yes

Long

Details:

Total size of a file.

Constraints:

Up to 5 GB

Default value:

N/A

Value range:

1-5368709120

file_type

Yes

String

Details:

File type

Constraints:

N/A

Options:

The value contains 1 to 64 characters.

Default value:

File name extension.

asset_id

Yes

String

Details:

Asset ID of the platform.

Constraints:

N/A

Options:

The value contains 1 to 64 characters.

Default value:

N/A

asset_file_category

Yes

String

Details:

File category in an asset. Each asset type contains different file categories.

  • MAIN: main file

  • COVER: thumbnail file

  • PAGE: image file of the PowerPoint content page

  • SAMPLE: sample audio or action file

  • OTHER: other files

  • WHOLE_MODEL: file of an entire model (3D virtual human)

  • USER_MODIFIED_MODEL: model uploaded by a user (3D virtual human)

NOTE:
  • When the asset type is SCENE, ANIMATION, VIDEO, IMAGE, or MATERIAL, categories are MAIN, COVER, and OTHER.

  • When the asset type is PPT, categories are MAIN, COVER, PAGE, and OTHER.

  • When the asset type is HUMAN_MODEL, categories are MAIN, COVER, WHOLE_MODEL, USER_MODIFIED_MODEL and OTHER.

  • When the asset type is VOICE_MODEL, categories are MAIN, SAMPLE (sample audio file), and OTHER.

  • When the asset type is HUMAN_MODEL_2D, categories are MAIN, COVER, SAMPLE (sample action), and OTHER.

  • When the asset type is BUSINESS_CARD_TEMPLATE, categories are MAIN and COVER (business card demo).

  • When the asset type is IMAGE, category is MAIN.

  • When the asset type is VIDEO, categories are MAIN and COVER.

Constraints:

An asset can have only one main file.

Options:

The value contains 1 to 128 characters.

Default value:

N/A

Response Parameters

Status code: 200

Table 4 Response header parameters

Parameter

Type

Description

X-Request-Id

String

Request ID.

Table 5 Response body parameters

Parameter

Type

Description

file_id

String

File ID.

upload_url

String

URL for file upload. The validity period is 24 hours.

NOTE:
  • Call the OBS API Uploading an Object - PUT to upload a file.

  • When calling the preceding API, specify the Content-MD5 header. The value must be the same as that in file_md5.

Status code: 400

Table 6 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error description.

Status code: 401

Table 7 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error description.

Status code: 500

Table 8 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error description.

Example Requests

POST https://{endpoint}/v1/6a6a1f8354f64dd9b9a614def7b59d83/files

{
  "file_name" : "1.png",
  "file_md5" : "n58IG6hfM7vqI4K0vnWpog==",
  "file_size" : 1048576,
  "file_type" : "png",
  "asset_id" : "8cb2f48a2cb006154794741933421100",
  "asset_file_category" : "MAIN"
}

Example Responses

Status code: 200

Successful.

{
  "file_id" : "b2f8a9e9c39b6dc7ed4c0cfd67366c6a",
  "upload_url" : "https://{endpoint}:443/0d697589d98091f12f92c0073501cd79/8cb2f48a2cb006154794741933421100/b2f8a9e9c39b6dc7ed4c0cfd67366c6a.jpg?AccessKeyId=XCQKTA8IWQPCAUQS4SDA&Expires=1671154644&Signature=vXxiJTO239WZcG8sniotTe9qOc4%3D"
}

Status code: 400

{
  "error_code" : "MSS.00000003",
  "error_msg" : "Invalid parameter"
}

Status code: 401

{
  "error_code" : "MSS.00000001",
  "error_msg" : "Unauthorized"
}

Status code: 500

{
  "error_code" : "MSS.00000004",
  "error_msg" : "Internal Error"
}

Status Codes

Status Code

Description

200

Successful.

400

Parameters error, including the error code and its description.

401

Authentication is not performed or fails.

500

Internal service error.

Error Codes

See Error Codes.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback