Skip to content

Commit

Permalink
removed writeHead from POST
Browse files Browse the repository at this point in the history
  • Loading branch information
valmassoi committed Apr 28, 2016
1 parent a39ffdb commit 3ed613f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "metadata",
"version": "0.2.0",
"description": "",
"version": "1.0.0",
"description": "Returns file size metadata from a file upload",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
Expand Down
13 changes: 6 additions & 7 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const express = require('express')
const http = require('http')
const multer = require('multer')
const upload = multer({ dest: 'uploads/' })
const fs = require('fs');
const fs = require('fs')

const app = express()

Expand All @@ -13,9 +13,8 @@ app.use(express.static(__dirname + '/public'))
app.get('/', (req, res) => {
res.sendFile('/public/index.html')
})
app.post('/uploads', upload.single('file'), function(req, res) {
// res.writeHead(200, {"Content-Type": "application/json"})
console.log(req.file);
app.post('/uploads', upload.single('file'), (req, res) => {
console.log(req.file)
res.json({
name: req.file.originalname,
size: req.file.size
Expand All @@ -29,10 +28,10 @@ app.get("*", (req, res) => {
})

function clearUploads(){
var path = __dirname + '/uploads/' ;
var path = __dirname + '/uploads/'
if( fs.existsSync(path) ) {
fs.readdirSync(path).forEach(function(file,index){
var curPath = path + "/" + file
fs.readdirSync(path).forEach((file,index) => {
let curPath = path + "/" + file
if(fs.lstatSync(curPath).isDirectory()) { // recurse
deleteFolderRecursive(curPath)
} else { // delete file
Expand Down

0 comments on commit 3ed613f

Please sign in to comment.