使用请求从节点stream上传到S3的问题

使用Node.js ,我试图上传一个大的文件(700MB〜1GB),作为响应POST请求(使用请求 ),到我的S3桶。 使用aws-sdk for Javascript iv'e尝试了两种方法,但每个都有一个不同的问题: 方法 1 – 尝试在response事件上调用s3.upload()函数: const sendRequest = (data) => { try { return new Promise((resolve, reject) => { AWS.config.loadFromPath('./config/awsConfig.json'); let s3 = new AWS.S3({ params:{ Bucket:'myBucket', Key:'path/to/file.csv' } }); request({ method: 'POST', uri: 'https://www.example.com/apiEndpoint', headers: { host: 'example.com', 'content-type': 'application/json' }, body: JSON.stringify(data) }).on('response', (response) => { // […]

在Webpack中使用节点通告器

我编写了一个用create-react-app(我使用Webpack和Babel)创build的Electron项目。 我想使用节点通知符,但是我在configurationWebpack时遇到了问题(我认为)。 通知调用的代码是从repo的自述文件复制粘贴。 我目前的Webpackconfiguration(我设法取消所以没有错误)是: node: { fs: 'empty', net: 'empty', tls: 'empty', child_process: 'mock', __filename: true, __dirname: true }, externals: [ 'ws' ], target: 'electron' 有没有人有一个如何configuration的想法? 我做错了什么,没有通知显示?

Node.js / Mongoose:发送信息到一个函数,并识别信息来操作

我有一个应用程序,它向3个不同的API REST服务器发出请求,收集并处理收到的对象信息,并使用mongoose的模型发送信息不同的Mongo集合(每个API REST一个)。 我的目标是在发送到MongoDB之前或同时(或之后)对不同的信息集进行操作。 下面是一个包含两个具体对象的例子,它们被检索并发送到数据库: Object1: { "name": "X", "a": 10, "b": 9, "n": 1502642712481, "iname": "ix", "_id": "59907f34040eb562d8d11d8c" } 对象2: { "name": "Y", "n": 1502642712552, "iname": "ix", "_id": "59907f34040eb562d8d11d8d", "b": "10", "a": "9", } 这些都有自己的模型,并正确插入到MongoDB保存,我想比较每个对象的“a”和“b”键(FYI: "iname"是一个共同的关键对象和"n"是在请求被返回时创build的时间戳)。 我想对'a'和'b'做的操作types是相对基础的math(目前): ax – ay和bx -by 任何想法,我怎么能做到这一点? 现在将每个对象保存到数据库的代码嵌套在一个无限循环中,如下所示: async function loopY() { setTimeout( async function () { var list […]

是否有可能在JavaScript中代理扩展类

我试图代理一个节点模块内的inheritance结构,并允许客户端实例化一个新的A类。当前当试图访问B类的父方法,我得到一个a.parentMethod is not a function handler.js -> module.exports = { get(target, key, receiver) { return target.getAttribute(key) }, set(target, key, value, receiver) { return target.setAttribute(key, value) } } A.js -> const handler = require('handler') class B { constructor(data) { this.data = data } parentMethod() { … do stuff } } class A extends B { constructor(data){ […]

Nodejs文件删除和错误:ENOENT:文件删除后没有这样的文件

我一直在争取这一段时间… 试图删除文件后,文件实际上被删除,但稍后会在大约30秒后出现此错误。 请帮忙 Error:ENOENT:no such file or directory,unlink'C:\ Users \ Adeoy3 \ IdeaProjects \ eym \ server \ audioFile \ Demand_and_Supply.mp3' 在错误(本机) 在Object.fs.unlinkSync(fs.js:1103:18) 在module.exports.deleteFile(C:\ Users \ Adeoy3 \ IdeaProjects \ eym \ server \ controllers \ audio-controller.js:187:8) (作为handle_request](C:\ Users \ Adeoy3 \ node_modules \ express \ lib \ router \ layer.js:95:5) (C:\ Users \ Adeoy3 […]

不是来自webpack的内容是从/ dist提供的

webpack.config.js var HtmlWebpackPlugin = require('html-webpack-plugin'); const path = require('path'); module.exports = { entry:'./src/app.js', output:{ path:path.join(__dirname, 'dist'), filename:'app.bundle.js', publicPath:'/dist/' }, , devServer: { contentBase: path.join(__dirname, "dist"), compress: true, stats: "errors-only", openPage: '', port:9000, open:true }, plugins: [new HtmlWebpackPlugin({ title:'Forum', filename:'index.html' //template:'./src/app.html' })] } 我的项目结构: ├── forum │ └── dist └── app.bundle.js ├── src │ ├── app.html […]

如何添加一个Spring Boot项目的Node模块?

我正在用Spring后端和React前端创build一个Web应用程序。 它的configuration基于这个最小的Spring Boot / React项目 。 现在我想在这个项目中使用react-checkbox-tree组件。 我该怎么做? 我尝试了两个不同的东西。 尝试1 在pom.xml文件中,使用以下声明包含React模块: <dependency> <groupId>org.webjars.npm</groupId> <artifactId>react</artifactId> <version>15.6.1</version> </dependency> 我试图find树组件的这种工件,但不能。 Attemp 2 我尝试将树组件安装为全局模块( npm install -g react-checkbox-tree )。 它没有帮助。 我得到错误 [INFO] ERROR in ./src/main/js/app.js [INFO] Module not found: Error: Cannot resolve module 'react-checkbox-tree' in C:\myproject\src\main\js [INFO] @ ./src/main/js/app.js 5:25-55 在build立。 更新1(13.08.2017 23:57): 在WebJars主页上,我find了关于如何将Node模块打包为WebJar的教程(以便它可以像正常的Maven依赖项一样集成到Spring Boot项目中)。 我开始为react-checkbox-tree创buildWebJar项目。 你可以在这里find源代码。 目前的问题是在本教程的pom.xml中提到的UPSTREAM_ZIP_URL : […]

创build – 反应 – 应用程序npm运行构build太慢

我对使用React相对来说比较新,并且正在学习create-react-app教程。 我正在Node环境中使用socket.io,React和Express创build一个简单的networking聊天服务。 我已经写完React应用程序的大部分function,现在正在服务器端通过Socket.io连接应用程序。 在前端工作是因为我可以运行“npm start”服务我的应用程序的开发版本。 但是,现在我在服务器端工作,实现Socket.io,每当我在前端发现问题时,我必须重新运行“npm run build”,每次需要15-30秒。 我确信有一个更快的方法来debugging这样的问题,而不必每次都编译我的反应的应用程序到静态文件。 请指教。

PostgreSQL 9.6.1数据库不显示在Heroku应用程序

我在Herokutesting应用程序中configuration了一个PostgreSQL数据库。 导航到URL / db不显示testing数据库,返回错误不能GET / db 。 Papertrail日志条目: https://papertrailapp.com/systems/glacial-bayou-96122/events?focus=833501717949202435&selected=833501717949202435 我已经包括了我提供数据库的步骤,并在下面列出了相关的代码。 我已经更新了我的package.json文件来添加pg npm module { "name": "node-js-getting-started", "version": "0.2.6", "description": "A sample Node.js app using Express 4", "engines": { "node": "6.11.1" }, "main": "index.js", "scripts": { "start": "node index.js", "test": "node test.js" }, "dependencies": { "ejs": "2.5.6", "express": "4.15.2" }, "dependencies": { "pg": "6.x", "ejs": "2.5.6", […]

Node.js Socket.io聊天示例不起作用

我刚刚开始与node.js,我在我的主机上安装节点,添加一些插件,我下载socket.io示例聊天 https://github.com/socketio/chat-example.git 当我运行它(节点index.js)我听到控制台上“聆听*:3000”的警报,它看起来像一切都会工作,但是当我到我的网站上端口3000(coracko.com:3000)聊天是可见的但消息不发送,也没有发生。 var app = require('express')(); var http = require('http').Server(app); var io = require('socket.io')(http); var port = process.env.PORT || 3000; app.get('/', function(req, res){ res.sendFile(__dirname + '/index.html'); }); io.on('connection', function(socket){ socket.on('chat message', function(msg){ io.emit('chat message', msg); }); }); http.listen(port, function(){ console.log('listening on *:' + port); }); <!doctype html> <html> <head> <title>Socket.IO chat</title> <style> * { […]