【发布时间】:2014-10-10 17:58:19
【问题描述】:
我使用 LocomotiveCMS 创建了一个网站,我创建了两种内容类型,称为照片和画廊,这些内容类型之间存在关系,因此我可以在我的网站上创建图片画廊。
我目前正在寻找使用 RESTful API 以便在 Photo 遍历文件时为其创建多个内容条目。
我可以毫无问题地连接到 API 并修改站点等。
我假设新内容条目的 cURL 命令将采用以下形式:
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
【问题讨论】:
标签: ruby-on-rails locomotivecms