メインコンテンツまでスキップ

アセット - Create asset

ルートURL​

POST https://playcanvas.com/api/assets

説明​

新しいアセットを作成します。

注記

現時点では、このエンドポイントは script、html、css、text、shader、および json のタイプのアセットの作成のみをサポートしています。

他のREST APIエンドポイントと異なり、Create Assetエンドポイントはデータの送信に multipart/form-data を使用する必要があります。

例​

curl -H "Authorization: Bearer {accessToken}" -X POST -F 'name={name}' -F 'projectId={projectId}' -F 'branchId={branchId}' -F 'parent={parent}' -F 'preload={preload}' -F 'pow2={pow2}' -F 'file=@./script.js' "https://playcanvas.com/api/assets"

HTTP リクエスト

POST https://playcanvas.com/api/assets
Authorization: Bearer {accessToken}
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryTdsfsfT

------WebKitFormBoundaryTdsfsfT
Content-Disposition: form-data; name="name"

{name}
------WebKitFormBoundaryTdsfsfT
Content-Disposition: form-data; name="projectId"

{projectId}
------WebKitFormBoundaryTdsfsfT
Content-Disposition: form-data; name="branchId"

{branchId}
------WebKitFormBoundaryTdsfsfT
Content-Disposition: form-data; name="parent"

{parent}
------WebKitFormBoundaryTdsfsfT
Content-Disposition: form-data; name="preload"

{preload}
------WebKitFormBoundaryTdsfsfT
Content-Disposition: form-data; name="file"; filename="script.js"
Content-Type: application/javascript

{fileContent}
------WebKitFormBoundaryTdsfsfT--

パラメーター​

名前タイプ必須デフォルト説明
namestring✔️—The name of the asset.
projectIdnumber✔️—The id of the project.
branchIdstring✔️—The id of the branch.
parentnumber—Parent asset's id.
preloadboolean—Preload the asset (true / false).
filefile—Data to store as the asset file.
pow2booleanfalseOnly used for textures. Resize the texture to power of two dimensions (true / false).

レスポンススキーマ​

Status: 201
{
"id": int,
"modifiedAt": date,
"createdAt": date,
"state": "ready" | "processing" | "error",
"name": string,
"type": string,
"scope":{
"type": string,
"id": int
},
"source": bool,
"sourceId": bool,
"tags": list of strings,
"preload": bool,
"data": {
... asset data
},
"file": {
"hash": string,
"filename": string,
"size": int,
"url": string
},
"parent": int
}

エラー​

コード説明
401Unauthorized
403Forbidden
404Project not found
429Too many requests

レート制限​

This route uses an assets rate limit.