前提・実現したいこと
node.jsでpostされたwavファイルを保存するサーバーをたてたいと思います.
発生している問題・エラーメッセージ
保存したwavファイルがなぜか再生できません.
該当のソースコード
保存するサーバーは以下の通りです.
js
1var fs = require('fs'); 2var http = require('http'); 3http.createServer(function (req, res) { 4 res.writeHead(200, {'Content-Type': 'audio/wav'}); 5 var out = fs.createWriteStream('hoge.wav'); 6 req.pipe(out); 7 res.end('end.'); 8}).listen(3333);
post側は以下の通りです.
python
1import requests 2 3post = "hoge.wav" 4url = "http://localhost:3333" 5files = {'upload_file': open(post, "rb")} 6res = requests.post(url, files=files) 7
試したこと
試しに中身が「hello!」というtxtファイルをpostしたところ
text
1--affc2c72a23b4684c52f22a50f4dbc21 2Content-Disposition: form-data; name="upload_file"; filename="post.txt" 3 4hello! 5--affc2c72a23b4684c52f22a50f4dbc21-- 6
となってしまいました.今回の問題と関係あるのでしょうか?
ご教授お願いします.
あなたの回答
tips
プレビュー