文件
最近更新: 2024年7月20日
创建对象:
- 管理员
Marketo订阅允许存储任意文件,如图像、脚本、文档和样式表。 所有这些都可以通过REST API远程使用。 Marketo订阅中提供的存储空间未针对带宽密集型应用程序进行优化,因此应该使用其他替代空间来应用适当的音频和视频流应用程序。
查询
查询文件非常简单,并遵循id为🔗的的资产、名称为的以及浏览的标准查询类型。
按Id
GET /rest/asset/v1/file/{id}.json
{
"success":true,
"warnings":[ ],
"errors":[ ],
"requestId":null,
"result":[
{
"id":147,
"size":61346,
"mimeType":"image/jpeg",
"url":"http://mlm.devlocal.marketo.com/rs/test/assets/rYXNeQFFVu",
"folder":{
"type":"Email",
"id":10613
},
"name":"rYXNeQFFVu",
"description":null,
"createdAt":"2014-12-09T22:33:57Z+0000",
"updatedAt":"2014-12-09T22:33:57Z+0000"
}
]
}
按名称
使用所需的name
参数指定文件的名称。
GET /rest/asset/v1/file/byName.json?name=foo.png
{
"success": true,
"warnings": [],
"errors": [],
"requestId": "9049#15918a76619",
"result": [
{
"id": 46488,
"size": 13987,
"mimeType": "image/png",
"url": "http://na-abm.marketo.com/rs/mktodemoaccount88/assets/foo.png",
"folder": {
"type": "Image",
"id": 436,
"name": "My Images"
},
"name": "foo.png",
"description": "This is a test file.",
"createdAt": "2015-05-06T22:16:58Z+0000",
"updatedAt": "2015-05-06T22:19:29Z+0000"
}
]
}
浏览
有三个可选参数:
- 文件夹 — 指定为JSON块的父文件夹,其中包含“id”和“type”属性
- offset — 指定从何处开始检索条目的整数(默认值为0);可以与maxReturn参数一起使用
- maxReturn — 指定返回的最大条目数的整数(默认值为20,最大值为200)
GET /rest/asset/v1/files.json?folder={"id":436, "type": "Folder"}&maxReturn=3
{
"success": true,
"warnings": [],
"errors": [],
"requestId": "17e4e#14e23372d80",
"result": [
{
"id": 46484,
"size": 1454,
"mimeType": "text/plain",
"url": "http://na-abm.marketo.com/rs/mktodemoaccount88/assets/websites.png",
"folder": {
"type": "Image",
"id": 436,
"name": "My Images - deverly"
},
"name": "websites.png",
"description": "This is a test file.",
"createdAt": "2015-05-06T20:15:58Z+0000",
"updatedAt": "2015-06-22T02:12:36Z+0000"
},
{
"id": 46486,
"size": 4169,
"mimeType": "image/png",
"url": "http://na-abm.marketo.com/rs/mktodemoaccount88/assets/mobile.png",
"folder": {
"type": "Image",
"id": 436,
"name": "My Images - deverly"
},
"name": "mobile.png",
"description": null,
"createdAt": "2015-05-06T22:13:33Z+0000",
"updatedAt": "2015-05-06T22:13:33Z+0000"
},
{
"id": 46488,
"size": 13987,
"mimeType": "image/png",
"url": "http://na-abm.marketo.com/rs/mktodemoaccount88/assets/foo.png",
"folder": {
"type": "Image",
"id": 436,
"name": "My Images - deverly"
},
"name": "foo.png",
"description": "This is a test file.",
"createdAt": "2015-05-06T22:16:58Z+0000",
"updatedAt": "2015-05-06T22:19:29Z+0000"
}
]
}
创建和更新
创建文件的过程是使用multipart/form-data类型的请求完成的。 最低限度,请求中需要名称、文件夹和文件,具有可选描述和insertOnly标志,这可以防止创建调用更新具有相同名称的现有文件。 对于文件参数,除了名称参数之外,Content-Disposition标头中还需要“filename”。 您还必须为文件传递Content-Type标头,它是Marketo将用于为文件提供服务的MIME类型。
POST /rest/asset/v1/files.json
------WebKitFormBoundary2VyWOacQSupl4gUL
Content-Disposition: form-data; name="file"; filename="marketo.html"
Content-Type: text/html
<html>
<body>
<h1>Test Page - marketo.html</h1>
</body>
</html>
------WebKitFormBoundary2VyWOacQSupl4gUL
Content-Disposition: form-data; name="name"
marketo.html
------WebKitFormBoundary2VyWOacQSupl4gUL
Content-Disposition: form-data; name="folder"
{"id":436,"type":"Folder"}
------WebKitFormBoundary2VyWOacQSupl4gUL
Content-Disposition: form-data; name="description"
This is a test file
------WebKitFormBoundary2VyWOacQSupl4gUL—
{
"success": true,
"warnings": [],
"errors": [],
"requestId": "278d#14e23316f63",
"result": [
{
"id": 46960,
"size": 69,
"mimeType": "text/html",
"url": "http://na-abm.marketo.com/rs/mktodemoaccount88/assets/marketo.html",
"folder": {
"type": "Image",
"id": 436,
"name": "My Images - deverly"
},
"name": "marketo.html",
"description": "This is a test file",
"createdAt": "2015-06-24T01:31:59Z+0000",
"updatedAt": "2015-06-24T01:31:59Z+0000"
}
]
}
可以根据文件ID更新文件。 唯一一个参数是文件参数,其要求与创建参数相同。
POST /rest/asset/v1/file/{id}/content.json
------WebKitFormBoundary2VyWOacQSupl4gUL
Content-Disposition: form-data; name="file"; filename="marketo.html"
Content-Type: text/html
<html>
<body>
<h1>Test Page - marketo.html</h1>
</body>
</html>
------WebKitFormBoundary2VyWOacQSupl4gUL--
{
"success": true,
"warnings": [],
"errors": [],
"requestId": null,
"result": [
{
"id": 67,
"size": 512000,
"mimeType": "image/png",
"url": "http://pages.devlocal.marketo.com/rs/test/assets/aLZiwCkXor",
"folder": {
"type": "Email",
"id": 10391
},
"name": "aLZiwCkXor",
"description": null,
"createdAt": "2014-12-18T09:03:43Z+0000",
"updatedAt": "2015-01-07T04:40:20Z+0000"
}
]
}
recommendation-more-help
bb269a6d-047a-4bf7-9acd-23ad9a63dc59