在AWS Lambda中,如果我创建一个带有后缀过滤器的事件源,例如export default class NumberField extends React.Component {
constructor (props) {
super(props);
this.state = {
value: !_.isUndefined(props.value) ?
props.formatter ? props.formatter(props.value).toString() : formatters.number(props.value).toString()
: null;
};
}
render () {
var props = this.props;
var state = this.state;
return (
<div>
<label>{props.inputLabel}</label>
<input
type="text"
name={props.name}
onChange={this.onChange.bind(this)}
value={state.value}
/>
</div>
);
}
onChange (e) {
var numValue = formatters.stringToFloat(e.target.value);
// if numValue is different from current state
// then it must be an OK update,
// so we update state AND call parent if function exists
if (numValue.toString() != this.state.value) {
this.setState({
value: numValue
},
this.callParent // here is the magic: we pass a callback, to be called after state update and after re-render
);
} else {
// otherwise we only update state (to display invalid character)
this.setState({
value: numValue
});
}
}
callParent() {
// state is updated and component has re-rendered when this is called
// so we can use state.value to inform parent
if (this.props.onChange) {
this.props.onChange({
value: this.state.value,
valid: validation.isValid(this.state.value, this.props.validation)
});
}
}
};
,我上传.jpg
lambda函数开始,它会创建一个名为.jpg
的缩略图。但问题是,一旦检测到xyz_thumbnail.jpg
上传到同一个存储桶,lambda进程将再次启动。所以我最终得到了无穷无尽的图像循环,即(xyz_thumbnail.jpg
,xyz_thumbnail_thumbnail.jpg
,xyz_thumbnail_thumbnail_thumbnail.jpg
),直到函数超时并死亡。
所以我的问题是如何使用xyz_thumbnail_thumbnail_thumbnail_thumbnail.jpg
过滤/排除任何后缀并将其添加到事件源?
答案 0 :(得分:1)
没有&#39;排除&#39;我所知道的选项,但有简单的解决方案:
我更喜欢前者。独立于源文件存储自动生成的文件更加清晰。