Commit f4e28ed6 authored by Mihkel Putrinš's avatar Mihkel Putrinš

refactor

parent f3b80d03
......@@ -168,14 +168,10 @@ document.getElementById('selectLocalButton').onclick = function selectLocal () {
op.set(resource, 'name', path.basename(single_file))
document.getElementById('resourceNameInput').value = resource.name
fs.stat(single_file, function(err, stats) {
if (err) {
throw (err)
}
if (err) { throw (err) }
if (stats.isDirectory()) {
fs.readdir(single_file, function(err, files) {
if (err) {
throw (err)
}
if (err) { throw (err) }
_paths = files.map(function(file) {
var fullpath = path.join(single_file, file)
return fullpath
......
......@@ -57,7 +57,6 @@ function addEntuFile(eid, file_path, callback) {
}
}
// var req = request.post(options, function (err, resp, body) {
var req = request.post(options, function (err) {
// console.log(err, resp, JSON.parse(body))
if (err) {
......@@ -69,13 +68,11 @@ function addEntuFile(eid, file_path, callback) {
}
})
var form = req.form()
var read_stream = fs.createReadStream(file_path)
form.append('file', read_stream)
form.append('entity', eid)
form.append('property', 'resource-file')
form.append('filename', path.basename(file_path))
req.form.append('file', read_stream)
req.form.append('entity', eid)
req.form.append('property', 'resource-file')
req.form.append('filename', path.basename(file_path))
read_stream.on('data', function(chunk) {
uploaded_files_progress += chunk.length
console.log('Uploaded: ' + uploaded_files_progress + '(+' + chunk.length + ')')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment