我创建了一个使用LocomotiveCMS的网站,我创建了两种称为照片和图库的内容类型,这些内容类型有一个关系,以便我可以在我的网站上创建图像库。如何通过机车CMS创建新的内容条目CMS RESTful API
我目前正在寻找使用RESTful API来为照片创建多个内容条目,因为它穿过一个文件。
我可以连接到API,没有问题,修改网站等
我会假设,一个新的内容条目卷曲命令将采取以下形式:
curl -X POST -d 'photo[image_id]=blah&photo[gallery]=1234&photo[file]=<filepath>photo[published]=true' 'http://<your site>/locomotive/api/current_site.json?auth_token=xxxx'
不过我我不确定如何通过这个命令传递一个文件,我现在已经替换了这个文件,你会如何编写这个部分?
我字段设置为图片如下:
fields:
- image_id:
label: Image ID
type: string
required: true
localized: false
- file: # Name of the field
label: File
type: file
required: true
localized: false
- gallery: # Name of the field
label: Gallery
type: belongs_to
required: true
localized: false
# Slug of the target content type (eg post if this content type is a comment)
class_name: gallery