0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

nodejsで容量が大きいデータをPOSTで受け取る時のやり方

Last updated at Posted at 2018-07-28

注意

自分用メモです。解説してません。

コード

sample.js
var http = require("http"),
    url = require("url"),
    request = require("request"),
    qs = require("querystring"),
    server = http.createServer();

server.on("request", function(a, b) {
    if ("GET" === a.method) var c = url.parse(a.url, !0).query;
    else if ("POST" === a.method) {
        var d = "";
        a.on("data", function(a) { d += a; });
        a.on("end", function() { c = qs.parse(d); });
    }
    
    b.writeHead(200,{'Access-Control-Allow-Origin' : '*'}),b.end("start" + c.functionName + " url: " + c.sp_url);
    
    request.get("https://script.google.com/a/earthship.co.jp/macros/s/AKfycbw7oix_3gO5k8yMzCNsx5dbduHrSKAVTWi1LZbe2P5NhKZOtvZs/exec?functionName=" + c.functionName + "&sp_url=" + c.sp_url);
});
server.listen(process.env.PORT, process.env.HOST);
console.log("server listening...");
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?