我在node.js中使用express 3创建文件上传功能.
我想抓取图像的文件扩展名.所以我可以重命名该文件,然后将文件扩展名附加到它.
app.post('/upload', function(req, res, next) {
var is = fs.createReadStream(req.files.upload.path),
fileExt = '', // I want to get the extension of the image here
os = fs.createWriteStream('public/images/users/' + req.session.adress + '.' + fileExt);
});
Run Code Online (Sandbox Code Playgroud)
如何在node.js中获取图像的扩展名?
所以基本上我正在使用 thunk 和 redux-promise-middleware 调度一个动作,这使得 API 调用返回一个承诺。然后我将返回的承诺作为“有效载荷”参数发送给另一个动作创建者,该参数与 redux-promise-middleware 一起使用并处理不同的动作 MY_ACTION_TYPE_PENDING 或 MY_ACTION_TYPE_REJECTED 或 MY_ACTION_TYPE_FULFILLED。我的问题是我是否通过 _REJECTED 操作处理 reducer 中的错误,而不是在我的 dispatch(actionCreator(payload)? _REJECTED ACTION 错误。
下面是我的一些操作:
export const RECEIVE_POSTS = 'RECEIVE_POSTS';
export const receivePosts = (data) => ({
type: RECEIVE_POSTS,
payload: data
})
// thunk middleware for fetching blog
export const fetchPosts = () => {
return (dispatch) => {
const payload = contentfulClient.getEntries().then(
data => data.items,
error => console.log('An error occurred in fetchPost thunk middleware', error)
)
return dispatch(receivePosts(payload))
.catch((error) => { …
Run Code Online (Sandbox Code Playgroud) javascript reactjs es6-promise redux redux-promise-middleware
在 React javascript 文件上使用 API 密钥时,是否有办法保护它的安全?例如;
emailjs.init("API_KEY");
Run Code Online (Sandbox Code Playgroud) javascript ×3
reactjs ×2
api-key ×1
client-side ×1
es6-promise ×1
file-type ×1
node.js ×1
redux ×1