我正在尝试使用createAsset使用内容管理api。
我使用的JavaScript脚本是
./contentful/contentful-import.js
const contentful = require('contentful-management');
const client = contentful.createClient({
accessToken:'AUTHTOKEN'
});
client
.getSpace('SPACE')
.then(space => {
space.createAsset({
fields: {
title: {
'en-US': 'Example 1'
},
description: {
'en-US': 'Example Description'
},
file: {
'en-US': {
contentType: 'image/jpeg',
fileName: 'example1.jpeg',
upload:'https://example1.jpeg'
}
}
}
}),
space.createAsset({
fields: {
title: {
'en-US': 'Example 2'
},
description: {
'en-US': 'Example Description'
},
file: {
'en-US': {
contentType: 'image/jpeg',
fileName: 'example2.jpeg',
upload:'https://example2.jpeg'
}
}
}
}),
//... 700 other assets
})
.then(asset => asset.processForAllLocales())
.then(asset => console.log(asset))
.catch(console.error)我运行的CLI函数是
contentful space migration ./contentful/contentful-import.js返回TypeError: migrationCreator is not a function的错误。
我在其他地方看过内容丰富的文档,但我找不到任何有帮助的地方。
我是试图正确上传资产,还是做错了什么?
发布于 2018-09-13 08:29:54
您编写的脚本是“正常”的node.js脚本。
node contentful-import.js会做得很好的。contentful space migration使用特定格式的特定脚本(它们必须导出migrationCreator)。有效的移徙是:
module.exports = function (migration, context) {
const dog = migration.createContentType('dog');
const name = dog.createField('name');
name.type('Symbol').required(true);
};内容-cli在引擎盖下使用内容迁移。你会在那里找到更多的文档。
我马上为CLI文档打开一个PR。:)
https://stackoverflow.com/questions/52301947
复制相似问题